#!/usr/bin/perl -w use Net::FTP; use Net::SSH::Perl; my($host,$user,$pass) = ("Server2","user_name","password"); my $cmd = "whoami"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); my $ftp = $ssh->cmd(Net::FTP->new("Server3", Debug => 0) or die "Cannot connect to Server3 $@"); $ssh->cmd($ftp->login("user_name",'password') or die "Cannot login ", $ftp->message); $ssh->cmd($ftp->cwd("/home/tmp") or die "Cannot change working directory ", $ftp->message); $ssh->cmd($ftp->put("file_in_server2") or die "get failed ", $ftp->message); $ssh->cmd($ftp->quit);