-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 At the beginning of the month, there was a discussion on killing an application in a script. One of the solutions given was the command for i in 'pidof spamd'; do kill $i; done Note: I know about killall, this is a different question. I thought it might be useful to be able to get the pid of an application into a variable, so I started experimenting with this as follows: for i in 'pidof spamd'; do echo $i; done The problem is that this solution doesn't work. $i will be 'pidof spamd', it does not contain the pid of spamd. Question: is there a way to get the pid into a variable, or was this simply a good idea that doesn't work? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFA1hetjeziQOokQnARAtAeAKCFIPpLt45dDogKF3CT6ksp+kw0HwCdHRHG XUYXatG/oUEiDl6U3GzTBBM= =h8X/ -----END PGP SIGNATURE-----
On Sunday 20 June 2004 4:02 pm, Michael Satterwhite wrote:
One of the solutions given was the command
for i in 'pidof spamd'; do kill $i; done
For that to work, they have to be backticks don't they? Scott -- POPFile, the OpenSource EMail Classifier http://popfile.sourceforge.net/ Linux 2.6.5-7.75-default
On Sun, 2004-06-20 at 16:02, Michael Satterwhite wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
At the beginning of the month, there was a discussion on killing an application in a script.
One of the solutions given was the command
for i in 'pidof spamd'; do kill $i; done
Note: I know about killall, this is a different question. I thought it might be useful to be able to get the pid of an application into a variable, so I started experimenting with this as follows:
for i in 'pidof spamd'; do echo $i; done
The problem is that this solution doesn't work. $i will be 'pidof spamd', it does not contain the pid of spamd.
Question: is there a way to get the pid into a variable, or was this simply a good idea that doesn't work?
cwsiv@linux:~> for i in `pidof kdeinit`; do echo $i; done 4442 3589 3587 3569 3568 3563 3554 3553 3551 3548 3547 3544 3532 3529 3527 3524 cwsiv@linux:~> if you use the -s parameter you only get the first process also it must be back ticks and the name must be exact. I tried to do this with evolution and it did not find it. I dont think regular expressions are part of pidof yet. CWSIV
participants (3)
-
Carl William Spitzer IV
-
Michael Satterwhite
-
Scott Leighton