time to start learning bash scripting

Stefan Jeglinski yellowdog-general@lists.terrasoftsolutions.com
Tue Aug 26 14:24:01 2003


My first bash scripting project is trivial: it simply checks whether 
a file exists, and moves it from one location to another (you gotta 
start somewhere). It works fine, but I want to also put a test in the 
script which moves the file depending on whether another program is 
running or not.

Being the screaming newbie I am at this, can someone give me a place 
to start? From my naive world view, I know whether the program is 
running based on

	ps caux |grep name_of_program

as just one example of the many ways I'm sure there are to do this.

 From my reading, I'm thinking that I can (should?) use awk inside of 
an if statement to extract the info in a form that can be branched 
on. In pseudocode:

if(name_of_program is in ps listing) {
	move file
} else {
	print error message and exit
}

The name_of_program in question will only ever have one instance in 
the ps list, FWIW.

How far off am I? I've been looking for awk tutorials and found some, 
but there is still a learning curve. From what I've read, I think sed 
is not the right tool for this (am I wrong?). Should I use Perl 
instead? Or, how about bash itself - does it have everything I need? 
Obviously, what I'm trying to do is not difficult.

Appreciative of any pointers to get me started.


Stefan Jeglinski