- 论坛徽章:
- 0
|
#!/usr/bin/perl
use Net::SSH::Perl;
my $host=$ARGV[0]; #主机IP
my $username=$ARGV[1]; #ssh用户名
my $password=$ARGV[2]; #密码
my $cmd=$ARGV[3]; #要执行的命令
my $ssh = Net::SSH::Perl->new($host,protocol => 2,debug=>1,options => [ "BatchMode yes", "RSAAuthentication no","PasswordAuthentication yes" ]);
$ssh->login($username,$password);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "$stdout, $stderr, $exit\n";
用此脚本测试登录linux服务器,可以执行任何命令; 奇怪的是登录windows2000后只能运行外部命令,而DOS的很多基本命令都是内部命令,用起来很不方便,请高手帮忙,谢谢! |
|