How can I run a command on a remote machine with Perl?
Posted
by Bharath Kumar
on Stack Overflow
See other posts from Stack Overflow
or by Bharath Kumar
Published on 2010-04-28T05:58:32Z
Indexed on
2010/04/28
16:03 UTC
Read the original article
Hit count: 390
perl
I'm using following code to connect to a remote machine and try to execute one simple command on remote machine.
cat tt.pl
#!/usr/bin/perl
#use strict;
use warnings;
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>2, Errmode=>'die');
$telnet->open('172.168.12.58');
$telnet->waitfor('/login:\s*/');
$telnet->print('admin');
$telnet->waitfor('/password:\s*/');
$telnet->print('Blue');
#$telnet->cmd('ver > C:\\log.txt');
$telnet->cmd('mkdir gy');
You have new mail in /var/spool/mail/root
[root@localhost]#
But when I'm executing this script it is throwing error messages
[root@localhost]# perl tt.pl
command timed-out at tt.pl line 12
[root@localhost]#
Please help me in this
© Stack Overflow or respective owner