An awk problem , need help! 
Author Message
 An awk problem , need help!

Hi there,

I am trying to kill certain processes in the process table by writing a
shell script which uses awk:

#!/bin/sh

ps -u > table.txt
awk '($2 != "p1" && $7 == "am" ) { print $2; system(kill -9 $2) }'
table.txt

The system call does not work! What is wrong here? Can I solve the
problem in another way? (the most excellent way would be perl. But it is
not available on that machine). Please help!

Thanks,

Mahmoud




Fri, 14 Jan 2000 03:00:00 GMT  
 An awk problem , need help!


Quote:
>I am trying to kill certain processes in the process table by writing a
>shell script which uses awk:
>awk '($2 != "p1" && $7 == "am" ) { print $2; system(kill -9 $2) }'

The "system" command needs a text string as its argument:

Quote:
>awk '($2 != "p1" && $7 == "am" ) { print $2; system("kill -9 " $2) }'

(Note the extra space after the "-9".)

Andrew



Fri, 14 Jan 2000 03:00:00 GMT  
 An awk problem , need help!

Quote:

> #!/bin/sh
> ps -u > table.txt
> awk '($2 != "p1" && $7 == "am" ) { print $2; system(kill -9 $2) }'
> table.txt

try to use this:
ps -u | awk '($2 != "p1" && $7 == "am" ) { print $2; system("kill -9 " $2) }'

the system-command needs a string as option.

Greetings, Lars.
--
   Lars Monecke             http://www.stud.uni-hannover.de/~lm/
  Unix-AG Hannover          http://www.stud.uni-hannover.de/unix-ag/
   PGP-Key unter            http://www.stud.uni-hannover.de/~lm/pgp-key.asc



Fri, 14 Jan 2000 03:00:00 GMT  
 An awk problem , need help!

Quote:

> awk '($2 != "p1" && $7 == "am" ) { print $2; system(kill -9 $2) }'

                                               ^^^^^^^^^^^^^^^^^^

system("kill -9 " $2);
--



Fri, 14 Jan 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. I need help with a devious AWK problem

2. need help using AWK

3. Need help with sed or awk !!

4. Need a bit of awk help, very new to it

5. newbie needs help with multiple expressions in awk

6. Need some help with awk addition

7. Need help with awk script

8. need help on awk script

9. Need awk (or sed) help PLEASE!

10. Need some awk help

11. Need little help with a awk script

12. URGENT: Need help with AND binary operation in awk

 

 
Powered by phpBB® Forum Software