shell

How to check an exectuable's path is correct in PHP?

I'm writing a setup/installer script for my application, basically just a nice front end to the configuration file. One of the configuration variables is the executable path for mysql. After the user has typed it in (for example: /path/to/mysql-5.0/bin/mysql or just mysql if it is in their system PATH), I want to verify that it is correc...

executing shell script without calling sh implicitly

Hi, I was wondering if it is possible to make a "link" in usr/bin (i.e.) that leads to a shell-script. But I want just to write % shellscript instead of % sh shellscript.sh kinda like an alias. Is this possible? ...

shell scripting error logging

Hi all, I'm trying to setup a simple logging framework in my shell scripts. For this I'd like to define a "log" function callable as log "LEVEL" $message Where the message is a variable to which I have previously redirected the outputs of executed commands. My trouble is that I get errors with the following {message=command 2>&3 1>...

collect the value returned by netstat into a variable

netstat -an | grep hypen echo $variable hypen | wc -l How to collect the value of netstat -an | grep echo $variable | wc -l to a varibale conn_count. ...

How to access GMail (IMAP Email) from my Shell/Python script to download a zip file attached to an email and process it?

I have to process a file everyday. This file is sent to my Email once everyday. If I can get to this email once every day and download the attachment, that had be awesome. Is it even remotely possible to do such a thing? Thanks! ...

Running matlab in the background

Hi, I am running matlab on 48 virtual machines and would like to automate it. I ssh into the machines then use matlab -r matlab_command > outfile.txt & to get the process to run in the background and run fine when I logout. The only problem is that when i jobs my process is stopped and won't start until I fg ^z bg. Is there a matlab f...

How to add the number of active netstat connections of different machine?

I've written this code to get the connections from one machine and adding them with the number of connection of the other machine. This code is not giving any netstat, 0 is coming for the live active connections. #!/usr/bin/ksh -xvf Machine_Detail="prpm@sp204|LC1_R11_LCP|LC1_R12_LCP|LC1_FR15_LCP|LC1_R16_LCP prpm1@sp2048|LC1_R13...

Check for messages apache Qpid

Is it possible to check for messages from Qpid queue from unix/windows console? Here is how I check via GUI : http://i47.tinypic.com/pbu5d.gif I can see all the info from Qpid JMX Management Console, is there a something close to this that I can use in console? ...

Combining echo and cat on Unix

Really simple question, how do I combine echo and cat in the shell, I'm trying to write the contents of a file into another file with a prepended string? If /tmp/file looks like this: this is a test I want to run this: echo "PREPENDED STRING" cat /tmp/file | sed 's/test/test2/g' > /tmp/result so that /tmp/result looks like this: ...

Finding missing files by checksum

Hi there, I'm doing a large data migration between two file systems (let's call them F1 and F2) on a Linux system which will necessarily involve copying the data verbatim into a differently-structured hierarchy on F2 and changing the file names. I'd like to write a script to generate a list of files which are in F1 but not in F2, i.e. t...

echo value inside a variable ?

x=102 y=x means when i echo $y it gives x echo $y x --and not 102 and when i echo $x it give 102 lets say I dnt know what is inside y and i want the value of x to be echoed with using y someting like this a=`echo $(echo $y)` echo $a Ans 102 ...

how to search for a term only in non test files

I use ack and I like it. However from time to time I need to search for something in my code base and I want to ignore all the files residing in test directory. Basically all the files which have test in their absolute path should be not included in the search. How do I achieve that? I am willing to have a custom bash script. Somethi...

How to test crontab entry?

I have an entry in my crontab that looks like this: 0 3 * * * pg_dump mydb | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz That script works perfectly when I execute it from the shell, but it doesn't seem to be running every night. I'm assuming there's something wrong with the permissions, maybe crontab is running under a different use...

How can I terminate a multicast stream (asr - Mac) in a script?

Hello, I'm making a script to to run a bunch of multicast asr streams, but I do not know how to "stop" or "end" a multicast asr stream after a certain amount of time. Loop Suspend does not do what I'm looking for. I've also tried to add a sleep command followed by a kill command, but they kick in after the stream ends (so that approach ...

shell scripting arithmetic operations

in general i will use expr inside shell scripts for doing arithmetic operations. is there a way where we can come up with arithmetic operation in a shell script without using expr? ...

Shell script to copy files

If there exist a directory, /backup/ And the files in it are a.gz b.gz c.gz And another directory /backup-directorybackup And the files in it are a.gz I need a shells script to compare two directories if the files are present then ignore it and if the filesare not present copy it to the destination directory Thanks.. ...

remove extended attribute : fails

From a shell script, I'm trying to remove extended attribute setfattr -x security.selinux file.txt The file.txt has mode as 777 but im getting "permission denied error" How to fix this ...

killproc and pidofproc on linux

Hi, I have a script which uses killproc and procofpid commands and executes fine on a 64bit suse. But when I executed the script on 32bit redhat , I found that the above commands donot exist. I don't have a 32bit Suse and 64bit redhat machines to test my script. Is my guess right that on 64bit redhat the above commands should be avai...

Windows Shell Programming book suggestion

Hi, I am a web developer using C#. I would like to experiment with Windows shell programming in C#. Many people suggests that using managed applications for shell program, is dangerous. (Creation of separate instances for each process versus in process shell. Also version dependency) Frankly speaking, I am totally new to shell. Is the...

How to replicate CTRL+C in a shell script?

I'm running a script that performs a command that lasts too long, so I want to interrupt it. Any help? I've tried to search a lot, and I've been pointed to the kill command. Although, I can't get it to work. By the way, I'm using a Mac OS X. Thanks! ...