Bash: how to get the PID of programs started?
I start a program from a script like this:
for line in `streamripper http://somesite.com/`; do ... done How could the script determine what is the PID of the streamripper process started? (There may be several streamripper processes already running.) I want to continuously monitor how the streamripper process proceeds. Streamripper outputs the necessary information periodically on the screen, but its output lines end with a CR character (so it puts everything on one line on the screen). How could the script cycle through these lines ending with CR? Is it possible to do this realtime? I mean the script should process each line immediately when it gets a line ended with the CR line delimiter, and it should not wait until it gets an LF line delimiter (the latter would cause several minutes of delay, and false operation). |
BASH Variables:
$$ = current pid !$ = last command issued $? = error code of last command $0 = command $1 = argument #1, also $2,$3,$4, etc. @ = full command line $_ = current shell I would fire up streamripper and pipe output to a script (Perl preferably) and stdout using tee. Yes it can be done. |
What about TCSH?
Does anyoen know if those BASH variables described above hold true for TCSH? And if not how would I go about getting the PID of a process I start in a TCSH script?
|
well try and see ;) do man tcsh also...
|
Nothing in man tcsh (I looked there first) and I tried to use them but wasn't sure if I was even doing it right.
|
sorry to break from the point here but something you hit on other1....
I am reading a tutorial on bash scripting at the moment and am coming across all sorts of bash variables like while [ $# -gt 1 ]; do and if file $ff. What do the $#, the $ff, the -gt 1 and so on mean here? And is there any place I can go to see a good listing of all these bash variables?? |
Just a quick note on the listing above that shows some BASH env variables, the second one down has the $ and ! mixed up.
|
two more corrections:
- the last one is only meaning the current shell at startup, then means the last argument of the previous command. - the one before (@) is missing a $ prefix. |
Yea, OK I screwed up. So my post was worth exactly what you paid for it! ;)
try these references: Bash Reference PDF or Linux in a nutshell or linux-bash or Bash HOW-TO or Advanced Bash Scripting Guide or Linux Scripting Tutorial or Google it. |
hey, on linux there's a program called pidof
you use it like this: pidof xmms and it will return you the program pid. ex.: #echo `pidof init` 1 *EDIT* (I guess I saw this on Debian... I was so sure it was a standard piece of software I posted this here without even trying it on my box - I'm using slack. I'll try to find out about it...) |
Quote:
Code:
man tcsh | grep process |
Quote:
This is a bash loop that reads "While the number of supplied arguments is greater than 1, do the following code and repeat". Not sure that $ff means anything in bash (unless you specified a $ff variable). |
All times are GMT -5. The time now is 08:54 AM. |