http://qs321.pair.com?node_id=1164077

Yedu has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

As part of SFTP process, I need to validate the remote folder before sftp'ing the files. We cannot have the Net::SFTP module installed on our servers.

I have written the following code to accomplish the same. *

#!/usr/bin/perl -i my $sftp_cmd = "sftp $usr\@$address <<EOF \n cd $remote_dir \nbye \nEO +F"; my $sftp_log = `$sftp_cmd`; if ($? == 0) { print "SFTP Completed Successfully"; } else { print "SFTP Failed"; }

* When I pass some wrong directory to $remote_dir, it is showing the information "Couldn't canonicalise: No such file or directory" in the command line. But finally, throwing the message "SFTP Completed Successfully".

Can some one please help how to handle this?

Is there any other variable that I should use instead of '$?' to check for the status?.

Thanks in Advance.

Regards,
Edu