The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> Linux Help
|
Awk xargs kill, illegal pid what's wrong?
Discuss Awk xargs kill, illegal pid what's wrong? in the Linux Help forum on Dev Shed. Awk xargs kill, illegal pid what's wrong? Linux Help forum discussing topics including usage, troubleshooting, modules, and distributions. Linux is an open source OS, based on UNIX.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 4th, 2012, 04:17 AM
|
|
Contributing User
|
|
Join Date: Jan 2008
Posts: 201
  
Time spent in forums: 1 Day 1 h 40 m 15 sec
Reputation Power: 8
|
|
|
Awk xargs kill, illegal pid what's wrong?
I have the following code. On cygwin I get the following erros:
$ torak
kill: illegal pid: User
kill: illegal pid: cons0
kill: illegal pid: 05:12:32
kill: illegal pid: /cygdrive/s/_flash/Motion-Twin/neko/neko
alias torak="ps -ef | awk '/cygdrive\/s\/_flash\/Motion\-Twin\/neko\/neko/{print $2}' | xargs kill"
What is the problem?
|

May 4th, 2012, 08:26 AM
|
|
|
|
What happens if you run the command without the final pipe into xargs by hand?
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|

May 4th, 2012, 06:25 PM
|
|
|
|
Maybe it's a line termination problem, you could try xargs -0
Just a guess.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
|

May 6th, 2012, 05:41 PM
|
|
Contributing User
|
|
Join Date: Jan 2008
Posts: 201
  
Time spent in forums: 1 Day 1 h 40 m 15 sec
Reputation Power: 8
|
|
@Doug It may be but i dont replacing it with null characters would be relevant in this case.
The output of the awk is:
Quote: $ ps -ef | awk '/cygdrive\/s\/_flash\/Motion\-Twin\/neko\/neko/{print $2}'
7184
|
Executing echo "6712" | xargs kill works
The output of:
echo "hello world" | awk '/hello/{print $1}' is
Last edited by imagenesis : May 6th, 2012 at 05:56 PM.
|

May 8th, 2012, 05:30 AM
|
|
|
|
I may have it. It's down to it being an alias - when you define it the variable $2 does not contain a value, so the alias value is invalid. Quote the $ (\$) to prevent it being evaluated at creation time and try that.
<edit>
Yes, that worked for me Use alias -p to see what is defined
</edit>
Last edited by SimonJM : May 8th, 2012 at 05:52 AM.
Reason: Tetsed it!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|