kill the ssh process called by the system command


P

priya

Once The eval alarm occurs it goes to the next host but my ssh for
the previous host is still hanging in the background process.How do i
kill the ssh once the timeout occurs?

foreach $host
eval {
local $SIG{ALRM} = sub {die "timeout\n"};
alarm 60;
system "$ssh","$host",$cmd
alarm 0;
};
if ([email protected] eq "timeou\n") {
printf("Aborted due to time out");
}
Thanx
priya
 
Ad

Advertisements

X

Xicheng

priya said:
Once The eval alarm occurs it goes to the next host but my ssh for
the previous host is still hanging in the background process.How do i
kill the ssh once the timeout occurs?
You may need to check CPAN's Expect modules, which is better suited in
these kind of jobs.

Xicheng
 
Ad

Advertisements

C

ced

priya said:
Once The eval alarm occurs it goes to the next host but my ssh for
the previous host is still hanging in the background process.How do i
kill the ssh once the timeout occurs?

foreach $host
eval {
local $SIG{ALRM} = sub {die "timeout\n"};
alarm 60;
system "$ssh","$host",$cmd
alarm 0;
};
if ([email protected] eq "timeou\n") {
printf("Aborted due to time out");
}


See perldoc perlipc ("Safe Pipe Opens"). Here's an excerpt:

# add error processing as above
$pid = open(KID_TO_READ, "-|");
...


hth,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top