I am trying to get files from server to another server through sftp. I am using this code upto now. But if the host is not connected its die and shows Unable to establish SFTP connection. But i need to raise an alarm (email) if its not connected through sftp.
#!/usr/bin/perl use warnings; use strict; use Net::SFTP::Foreign; my $host = 'xxx.xx.x.xxx'; #Host adress my $password = 'teledna'; #Password for host my $path = "/root/sanjay/"; #Path where .csv file present #connecting to host using SFTP my $sftp = Net::SFTP::Foreign->new($host, password => $password); $sftp->die_on_error("Unable to establish SFTP connection"); #Changing the path to .csv directory $sftp->setcwd($path) or die "unable to change cwd: " . $sftp->error; #get("Name of file in remote server","Name you have to given to file") $sftp->get("database.csv", "database.csv") or die "get failed: " . $sf +tp->error;
In reply to Need alarm while getting error on SFTP by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |