|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
detect a running process
Hi!
Trying this forum for help with my script. Running AIX and script is Kornshell. My goal is to automate installation of program modules, mainly Perl and Kornshell. I've got an old script doing the following to detect a running program (which will not be installed as it is currently running). My question is: 1) Will it work? (I have tried it but it doesn't seem to deliver the right output.) 2) What exactly does the "sed" part do? 3) Is there a better way? code: pattern=$( print $program | sed -e ´s!^.![ /][&]!´ -e ´s/$/[ $]/´ ps -ef | grep -v $PROGRAM | grep "$pattern" >/dev/null && log "Unable to install, $program is running" || installroutine //Best regards |
|
#2
|
|||
|
|||
|
RE: detect a running process
Sorry if I took your time,
now it's running. //Staffan |
|
#3
|
|||
|
|||
|
RE: detect a running process
try:
#!/bin/sh PROC=`ps -ef | grep <process> | grep -v ${0} | sed -e 'print $2'` if [ ${PROC} ] ;; then echo "proc is running" fi You'll need to swap out the <process> with whatever you are checking for. 'ps -ef' might need to change, based on your OS. Under Linux, for example, you want 'ps -aux'. You also may need to switch out the 'sed -e 'print $2', and change the $2 to a different column. If you do a ps -aux, you want the column of the pid to be reflected by this. The counting starts at 1, instead of 0, so the first column listed will be $1. I know this script isn't ksh, but I think it'll work there. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > detect a running process |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|