perl ssh with timeout?

M

Markus Dehmann

How can I use perl to connect to a remote computer via ssh with a timeout?

I saw the modules Net::SSH and Net::SSH::perl, but didn't see timeout
options. The latter one I wasn't able to install anyway (the required
Crypt::DH never finishes its tests in CPAN shell).

Maybe just use the system command? But it also does not have a timeout?

BTW, all computers I want to connect to don't require my password, so
getting a connection should be straightforward.

Thanks!
Markus
 
R

Rick Scott

(Markus Dehmann said:
How can I use perl to connect to a remote computer via ssh with a
timeout?

Use alarm to send yourself a SIGALRM in $timeout seconds, then install
a function that handles SIGALRM.

This is a frequently asked question. You can use
perldoc -q keyword
to search the Perl FAQ for the given keyword; in this case,
perldoc -q timeout
would have given you the answer you are looking for. See also:

perldoc -f alarm
perldoc perlipc




Cheers,
Rick
 

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

Members online

Forum statistics

Threads
474,183
Messages
2,570,969
Members
47,524
Latest member
ecomwebdesign

Latest Threads

Top