Sep 14, 2004 #1 jliang MIS Apr 26, 2004 30 US Hi, I write a Korn shell script to use LET command to calculate how many processes are running. the syntax is: LET "activejob='ps -ef|grep 'test.sh'|wc -l '" but I got syntax error. Can you help me with this problem? Many thanks in advance. Jing
Hi, I write a Korn shell script to use LET command to calculate how many processes are running. the syntax is: LET "activejob='ps -ef|grep 'test.sh'|wc -l '" but I got syntax error. Can you help me with this problem? Many thanks in advance. Jing
Sep 14, 2004 #2 olded Programmer Oct 27, 1998 1,065 US Jing: The LET is optional, and you're using the wrong command substitution character. Use the grave mark ` not the quote ': activejob=`ps -ef|grep -v 'grep test.sh'|grep 'test.sh'|wc -l ` I also included grep -v to ignore that command in the process table. You can also use the ksh method of command substituition: activejob=$(ps -ef|grep -v 'grep test.sh'|grep 'test.sh'|wc -l Regards, Ed Upvote 0 Downvote
Jing: The LET is optional, and you're using the wrong command substitution character. Use the grave mark ` not the quote ': activejob=`ps -ef|grep -v 'grep test.sh'|grep 'test.sh'|wc -l ` I also included grep -v to ignore that command in the process table. You can also use the ksh method of command substituition: activejob=$(ps -ef|grep -v 'grep test.sh'|grep 'test.sh'|wc -l Regards, Ed
Sep 14, 2004 #3 stefanwagner Programmer Oct 19, 2003 2,373 DE The linux-ps accepts Code: grep -C test.sh which avoids the negative-grep for 'grep test.sh'. Perhaps your ps too? seeking a job as java-programmer in Berlin: http://home.arcor.de/hirnstrom/bewerbung Upvote 0 Downvote
The linux-ps accepts Code: grep -C test.sh which avoids the negative-grep for 'grep test.sh'. Perhaps your ps too? seeking a job as java-programmer in Berlin: http://home.arcor.de/hirnstrom/bewerbung
Sep 15, 2004 Thread starter #4 jliang MIS Apr 26, 2004 30 US Hi, ED, It works fine. Thanks very much Jing Upvote 0 Downvote
Sep 20, 2004 #5 PHV MIS Nov 8, 2002 53,708 FR You may also try this: activejob=$(ps -fe | grep -c '[t]est.sh') Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244 Upvote 0 Downvote
You may also try this: activejob=$(ps -fe | grep -c '[t]est.sh') Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244