shell-scripting

php safe_mode_exec_dir help

I am hoping to find some more information about this PHP setting, I assume I need to change its value in the php.ini but I set the root the folder as /file/path/ or as http://www.domain.com/file/path? Any advice would be great ...

How Can i Rename All Files in a Directory using For Loop?

Here is my snippet: #!/bin/sh for fname in * do if [! -d "$fname"] then WHAT CAN I DO fi done All new named files has to have this format O.fname - as you see preceeded by O. Can you please help? I know i have to use mv somewhere. ...

how to get Difference of two variables

I am new to shell scripting. I want to know is there a way in which I can get a difference of two strings or values of two variables. There are two variables: value1 = "alok" value2 = "kumar alok" so I want to get a result as result = value1~value2 my expected result is result="kumar" is there any way I can do it? can some...

How join 2 variable in shell script ?

INPUT=10 OUTPUT_IN=20 KEYWORD="IN" echo $OUTPUT_"$KEYWORD" It should display 20 Mainly I am looking to generate the variable name OUTPUT_IN How to resolve this? ...

Looking for a more efficient (and portable) way to obtain (numeric) file permissions in unix

Short background: I need to monitor the permissions on a unix file (a directory) with ZABBIX to see if/when they change. ZABBIX doesn't have any built in like vfs.file.mode[xxxx] for this, so I had to roll my own UserParameter, with a numeric type. What I do so far, is use ls -l | cut -c 2-10 to get the rwxr-xr-xpart, and then use sed t...

Is it possible to set an environment variable to the output of a command in cmd.exe

I need to do the equivalent of set ENVAR=`some-command` In a windows/cmd.exe script. Cygwin is not an option. For bonus marks: Is there some cmd.exe equivalent of backticks in general? ...

sql from shell script

Hi, I have the below shell script in which sql file is called which has set of select and insert statements. Right now it's spooling output/error of the sql select /insert commands to the csv file. I want the output and error of the sql commands redirected to the shell script LOGFILE instead of spool file. How can i do it. LOGPATH=${...

unix shell programming special variables

I need a good reference on unix shell special variables (csh, ksh and bash). e.g. $1, $*, $#, etc. ...

Need Help Creating Multiple Directories in Makefile

I have the following block of code in a makefile: param_test_dir: @if test -d $(BUILD_DIR); then \ echo Build exists...; \ else \ echo Build directory does not exist, making build dir...; \ mkdir $(BUILD_DIR); \ fi @if test -d $(TEST_DIR); then \ echo Tests exists...; \ else \ echo Tests directory does not e...

Makefile Makeover -- Almost Complete, Want Feedback

Hi Everyone, I've been heavily refactoring my makefiles, with help from Beta, Paul R, and Sjoerd (thanks guys!). Below is my STARTING product: #Nice, wonderful makefile written by Jason CC=g++ CFLAGS=-c -Wall BASE_DIR:=. SOURCE_DIR:=$(BASE_DIR)/source BUILD_DIR:=$(BASE_DIR)/build TEST_DIR:=$(BASE_DIR)/build/tests MAKEFILE_DIR:=$(BASE_D...

How can I standardize shell script header #! on different hosts?

I manage a large number of shell (ksh) scripts on server A. Each script begins with the line... #!/usr/bin/ksh When I deploy to machine B, C, and D I frequently need to use a different shell such as /bin/ksh, /usr/local/bin/ksh or even /usr/dt/bin/ksh. Assume I am unable to install a new version of ksh and I am unable to create links ...

ssh to different machine to find the number of file.

echo "`${BOLD}` ***** Checking CoreFile Creation *****`${UNBOLD}`" echo "========================================================" IFS='|' cat configMachineDetails.txt | grep -v "^#" | while read MachineType UserName MachineName do export CHK_COREFILE=`ssh -f -T ${UserName}@${MachineName} ls ~/corefiles ...

Simulate User Input To Call Script Multiple Times With Different Parameters

I have to use a provided script that takes user input while the script is running instead of parameters. I can't get around this. An example of script would be: #!/bin/bash echo "param one" read one doSomething echo "param two" read two doSomething echo "param three" read three doSomething echo "param four" read four doSomething e...

Shell script to find, search and replace array of strings in a file

This is linked to another question/code-golf i asked on http://stackoverflow.com/questions/3171552/code-golf-color-highlighting-of-repeated-text I've got a file 'sample1.txt' with the following content: LoremIpsumissimplydummytextoftheprintingandtypesettingindustry.LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenan...

vim - write buffer content to stdout

Is there any chance to write the content of the current vim buffer to stdout? I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the modified content. (on Linux/Unix) Added: Is it possible that a plugin/script - that act on quit or save put the buffer content to stdout? ...

Validate status of URLs in a mysql Database using CURL and shell script.

Good day, I have a simple MySQL database with 1 table and 3 fields Table: LINKS Fields: ID URL STATUS The table has about 3 millions links. I would like to check all the URLs and post their returned status in the status field so that I can remove the dead links later. This would probably require a shell script because it will nee...

Optimizing Rails loading for maintenance scripts

Hello, I wrote a script that does maintenance tasks for a rails application. The script uses a class that uses models defined in the application. Just an example, let's say application defines model User, and my class (used within the script), sends messages to it, like User.find id. I am looking for ways to optimize this script, becau...

Loop on a directory and do some analysis by using shell Script

Hello, Problem Description: i have a directory with a set of files and these files name saved in table into database called "File_names" i want to make shell script that loop on the directory and each time search if that file name exist in the database or not ,then if no : insert that name into database . else do nothing. My trail: ...

TARing relatively.

Hi, I'm writing a script that can tar any given folder and place it in my home/bkp. the script will read like this, tar czvf /home/me/bkp/`basename $1`.tar.gz $1 well now, to use it., backup-script.sh /home/me/folder/sub/to-be-backed-up/ Well and good. Now when I untar it, it creates home/me/folder/sub/to-be-backed-up/*file...

Increase the performace of the code by reducing the number of ssh

This function take hugh amount of time to calculate the status of a process, beacuse every time it has to ssh into the machine and find the status of a process. I only have four machines and around 50+ process to monitor and the details are mentioned into configDaemonDetails.txt like: abc@sn123|Daemon_1|processname_1 abc@sn123|Daemon_...