简体   繁体   中英

How to check if remote directory exists using Net::SSH::Perl

Check to see if remote directory exists using Perl Net::SSH::Perl

I want to check if a directory exists on a report server using the Net::SSH::Perl module.

This command works:

my($stdout, $stderr, $exit) = $ssh->cmd("ls -al /home/mydir");

But how can I do like:

if ( ! -e "/home/mydir/mydir_1" ) {
   mkdir "/home/mydir/mydir_1";
}

Any way to do this using this Perl module?

mkdir-p选项可以完成你想要的(如果存在则没有错误),所以类似于:

my($stdout, $stderr, $exit) = $ssh->cmd("mkdir -p /home/mydir/mydir_1");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM