CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Error issuing system kill command

 



justij
New User

Nov 16, 2012, 9:03 AM

Post #1 of 2 (1155 views)
Error issuing system kill command Can't Post

I am attempting to issue the following kill command which works in the shell but not in my program...

CODE:

print "Performing agent status check...\n";

eval {

local $SIG{ALRM} = sub {die "alarm\n"};

alarm 30;

system("/oradba/app/oracle/product/agent12g/agent_inst/bin/emctl","status","agent");

alarm 0;

};

if($@) {

die unless $@ eq "alarm\n";

print "Agent status check timed out, killing agent processes...\n";

system("/usr/bin/ps -ef | /usr/bin/grep '[a]gent12g' | /usr/bin/awk '{print $2}' | /usr/bin/xargs /usr/bin/kill");

print "Process IDs have been killed, restarting agent...\n";

ERROR:

Performing agent status check...

Oracle Enterprise Manager 12c Cloud Control 12.1.0.1.0

Copyright (c) 1996, 2012 Oracle Corporation. All rights reserved.

---------------------------------------------------------------

Use of uninitialized value in concatenation (.) or string at

./agent_bounce_test.pl line 53 (#1)

(W uninitialized) An undefined value was used as if it were already

defined. It was interpreted as a "" or a 0, but maybe it was a mistake.

To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation

you used the undefined value in. Note, however, that perl optimizes your

program and the operation displayed in the warning may not necessarily

appear literally in your program. For example, "that $foo" is

usually optimized into "that " . $foo, and the warning will refer to

the concatenation (.) operator, even though there is no . in your

program.

Agent status check timed out, killing agent processes...

/usr/bin/kill[8]: oracle: Arguments must be %job or process ids

Thanks in advance for any help.



justij
New User

Nov 16, 2012, 12:23 PM

Post #2 of 2 (1147 views)
Re: [justij] Error issuing system kill command [In reply to] Can't Post

Solved issue. An escape character was needed in the awk argument when passing the command to the shell.

system("/usr/bin/ps -ef | /usr/bin/grep '[a]gent12g' | /usr/bin/awk '{print \$2}' | /usr/bin/xargs /usr/bin/kill ");

Regards

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives