I wish to check whether a path given is exists or is a directory in another site server in Perl. My code is as below.
my $destination_path = "<path>";
my $ssh = "usr/bin/ssh";
my $user_id = getpwuid( $< );
my $site = "<site_name>";
my $host = "rsync.$site.com";
if ($ssh $user_id\@$host [-d $destination_path]){
print "Is a directory.\n";
}
else{
print "Is not a directory.\n";
}
I am sure my code is wrong as I modify the code according to bash example I see from another question but I have no clue how to fix it. Thanks for everyone that helps here.
[
is the name of a command, and it must be separated from other words on the command line. So just use more spaces:To actually execute this command, you'll want to use the builtin
system
function.system
returns 0 when the command it executes is successful (see the docs at the link)Accessing the remote file system through SFTP: