![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| shell script that would display installing.... when installign something | eamani_sun | Shell Programming and Scripting | 1 | 05-14-2008 01:51 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | SuSE | 5 | 07-30-2007 08:26 AM |
| Command Not running in script | Dastard | Shell Programming and Scripting | 2 | 05-21-2007 05:08 PM |
| Need to know rhe PID for the Shell Script running | pbsrinivas | Shell Programming and Scripting | 7 | 01-25-2007 09:10 AM |
| Shell Script Display? | wmosley2 | UNIX for Dummies Questions & Answers | 2 | 12-14-2003 02:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
PS command does not display shell script running
Quote:
Otherwise, know that whenever you execute a script--an executable file that begins with #!--the operating script automatically converts the command to the form Code:
interpreter script_name Code:
#!/bin/bash echo "Hello World!" > ./myscript rather than passing the script name as an argument to the interpreter > bash myscript when the operating system spots that the file is a script--beginning with #!--it converts the command to the form "/bin/bash ./myscript". Some versions of ps--not all of them--will print the process's command name as "interpreter" (here "bash"), rather than as the script name. This is why you are seeing -sh as the command name of the process--does your script start with #!/bin/sh? To get around this, try format options of ps, with the -o switch. Try ps -o pid,args. This should list your processes with two columns: the first the PID of each process; and the second the complete command with which that process was invoked, which for scripts wil be of the form "interrpeter scriptname". So you should be able to search for the name of your script in the output of ps, like with grep or awk. Try: Code:
pid=`ps -o pid,args | awk '/script_name/ { print $1 }'`
Last edited by hadarot; 09-10-2005 at 01:07 PM.. |
|
||||
|
Thank you
i am not using #!bin/bash and i am executing withhout ./ I am executing directly by typing scriptname.sh from prompt. ps -o does not work on my system how to get the get pid from scriptname?any other ways? thanks martin |
![]() |
| Bookmarks |
| Tags |
| grep or |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|