![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pass arguments to called program | ShellUser | Shell Programming and Scripting | 2 | 01-22-2008 05:34 AM |
| not able to kill find with kill -9 | Amardeep | UNIX for Dummies Questions & Answers | 5 | 01-04-2007 01:49 PM |
| When kill doesnt work, how to kill a process ? | VijayHegde | UNIX for Advanced & Expert Users | 3 | 05-12-2006 01:24 PM |
| pass pid to kill using script | hcclnoodles | Shell Programming and Scripting | 2 | 10-29-2004 09:19 AM |
| How to pass arguments to a function in a shell script? | preetikate | Shell Programming and Scripting | 3 | 03-01-2004 12:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Pass Kill with arguments
Dude,
I want to kill a process, but the processid is in a text file. I have to read the text file for the process id and pass it as parameter to the kill command. Example $ cat prcid.txt 18650 I want to pass the value 18650 as a process id to kill command. $ kill -9 <value read from the prcid.txt file> The complete statement should be something like this... $ cat prcid.txt | kill -9 <processid from txt file> Thanks, Muralee |
| Forum Sponsor | ||
|
|
|
|||
|
kill -9 $(cat file)
The $(....) construct spawns a subshell and expands to the output of the shell, much like "$var" would expand to the content of the variable var. You can even put several commands inside, like here: Code:
if [ $(some_command >/dev/null ; print - $?) -gt 0 ] ; then
print - "the return code was greater zero"
else
print - "the return code was zero"
fi
bakunin |
|
|||
|
Thanks for the reply. But things are not over....
To get more detailed, prcid.txt file has two process ids like below: $ cat prcid.txt 18734 18733 prstat First one (18734) is pid and the other is (18733) is ppid, so i want to pass arugment to kill as below to terminate the process and the parent process. $ kill -9 pid -ppid. I want to do some thing like below $ kill -9 $(cat prcid.txt | cut -d" " -f1) -$(cut prcid.txt | cut -d" " -f2) Thanks, Muralee |