
guna
New User
Jan 7, 2008, 5:09 PM
Post #1 of 2
(1809 views)
|
|
Perl script for SSH connection
|
Can't Post
|
|
Hi, I am new to perl and trying to connect the remote Unix server through SSH port from my windows server. Is there any pre-written program to to achieve this. or pls. tell me other possibilities to achieve this Pls. help me... Thanks in advance !!! I used the following script but during compilation it throws the error weak references are not compiled. #!/usr/bin/perl use strict; my $host="rc-hp39"; my $user="ca5555"; my $pass="passxx"; my $cmd="pwd"; use Net::SSH::Perl; my $ssh=Net::SSH::Perl->new($host); $ssh->login($user,$pass); my ($stdout,$stderr,$exit)=$ssh->cmd($cmd); print "Here is your present working directory : $stdout\n"; # you can run multiple commands just by invoking "my ($stdout,$stderr,$exit)=$ss h->cmd($cmd); everytime or you might want to set up interactive shell"; # you will need to load the module Term::Readkey for that # here is the additional code for that # use Term::ReadKey; # ReadMode('raw'); # $ssh->shell; # ReadMode('restore');
|