shell-scripting

Shell Script with Zenity

Using Zenity is possible to add buttons,change fonts ,anything besides default options? If not,there's another dialog for sh that allows more customizing? ...

What commands must I learn to become an effective Linux shell script programmer?

I have recently started moving into the world of Linux development. I wanted to learn some new things and thought bash might be fun. As I learn more about bash programming I have found that there are quite an assortment of useful tools to be used (such as grep, tr, awk, etc.) There are so many that I just do not know which ones are "vita...

Using variable with sed in Shell Script

I'm writing a shell script to edit Change-Set attributes of aegis. The command I'm using is: aegis -Change_Attributes -Edit which opens up a vi editor to carry out the changes. I want to do a search and replace: s/brief_description \= \"none\"\;/brief_description \= \"test\"/g Can I pass these directly to th...

Read user input with spaces in csh Shell Script

I have a script where the user should be able to enter a string with spaces. So far I have: #bin/csh echo "TEST 1" echo -n "Input : " set TEST = $< echo "Var | " $TEST set TEST=`echo $TEST` echo "Var after echo | " $TEST set TEST=`echo $TEST | sed 's/ /_/g'` echo "Var after change | " $TEST If I enter the string "r r r" at "inpu...

Script with nawk doesn't print output to screen

I came across a nice one-liner to search for text and print out the results with a given number of trailing and following lines. I'm trying to create a script out of this. So far this is what I have: # ********************************************************* # This uses nawk to list lines coming prior to and after # the given search st...

How to mkdir only if a dir does not already exist?

I am writing a script to run under the korn shell on AIX. I'd like to use the mkdir command to create a directory. But the directory may already exist, in which case I don't want to do anything. So I want to either test to see that the directory doesn't exist, or suppress the "File exists" error that mkdir throws when it tries to create ...

Will this redirection ">>& <filename>" work in Korn shell?

I am trying to redirect both STDOUT/STDERR of a UNIX command and append to a log file in a korn shell. rm -rf file1 >>& logfile Will this command work in ksh or is this a typical bash command? What harm would I be causing with above command? ...

backup MySql databases and email them somewhere at a certain time

We're running a CentOS server with a lot of MySql databases atm, what I need is a really easy way for us to back those up. Since many of them are under a couple of meg. Dumping, zipping them up then sending them to a secure Google Apps account sounds like a pretty good idea. So what I need is: a script that will dump and zip the databas...

Cron to Log the ip of a repository with a dynamic ip

Hi, I am using a mac mini with a dynamic ip to store an SVN repository. As an unexpected change of the ip makes it difficult to consistently use the repository, I am interested in creating a cron to log the ip on another server every time it changes. What would be the best way to do this? ...

Windows Shell Script - Closing the command prompt

Guys, I assume this is pretty easy so here goes; I'm trying to execute these commands and then close the command prompt after Firefox opens. How do I do that? I can't get back to a command prompt after "ping 127.0.0.1 -n 4>null" (i'm simulating a sleep here). @echo off call tskill firefox call ping 127.0.0.1 -n 4>nul call C:\"Program...

BASH: Possible to abort shell script if any command returns a non-zero value?

I have a Bash shell script that invokes a number of commands. I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value. Is this possible without explicitly checking the result of each command? e.g. dosomething1 if [[ $? -ne 0 ]]; then exit 1 fi dosomething...

Executing commands containing space in bash

I have a file named cmd that contains a list of unix commands as follows: hostname pwd ls /tmp cat /etc/hostname ls -la ps -ef | grep java cat cmd I have another script that executes the commands in cmd as: IFS=$'\n' clear for cmds in `cat cmd` do if [ $cmds ] ; then $cmds; echo "****************************"; ...

GtkDialog in shell

I'm using gtkdialog in shell script but I got stuck.I tried "use-markup" to format the font,however it appears does not work.Is not there anything like ? And if the program has several widgets the layout always be disorderly... Is there a solution?Or a good tutorial on gtkdialog?(I searched but could not find one besides the user-manual)...

Invoke external shell script from PHP and send some input to it

Hi All, my aim is to invoke a shell script from a PHP program and then wait for a few seconds to send some termination key to it (I can't simply kill it because I want to test the correct execution of the termination phase). Here is an example of what I'd like to have: system( "RUNMYSCRIPT.sh" ); // Launch the script and return immedi...

handling login in an automated backup script

I need to write a shell script to be scheduled to run daily to backup a directory using mercurial. I have got most of the use cases done except I can figure out a way to do automated login while the script is running. for REPOSITORY in $@ do cd $REPOSITORY # commit the changes hg commit -A -m "Commit changes `date`" #...

logging mercurial transactions

this is a small addition to the previous script, and this time I would like to log details for the backup. script /tmp/commit-push-log # add all files to the repository for REPOSITORY in $@ do cd $REPOSITORY # commit the changes hg commit -A -m "Commit changes `date`" # push the changes to the remote repository ...

Shell Script - Get all files modified after <date>

I'd rather not do this in PHP so I'm hoping a someone decent at shell scripting can help. I need a script that runs through directory recursively and finds all files with last modified date is greater than some date. Then, it will tar and zip the file(s) keeping the path information. Thanks in advance! ...

Line error in shell script

I have the following code in a shell script. This only seems to work when it is not defined in a function. The problematic line is the one containing the "<<". The error message is "./run: line 210: syntax error: unexpected end of file" How can I write this correctly within a function? init_database() { cd ../cfg db.sh ...

How do I write some (bash) shell script to convert all matching filenames in directory to command-line options?

Apparently the answer to my question "Can I restrict nose coverage output to directory (rather than package)?" is no, but I can pass a --coverage-package=PACKAGE option to nose with the package name of each .py file in the directory. So for example, if the directory contains: foo.py bar.py baz.py ...then I would need to use the comma...

Printing hard copies of code

I have to hand in a software project that requires either a paper or .pdf copy of all the code included. One solution I have considered is grouping classes by context and doing a cat *.extension > out.txt to provide all the code, then by catting the final text files I should have a single text file that has classes grouped by context. T...