Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
laziness, impatience, and hubris
 
PerlMonks  

Re: Getting information about a remote file via SSH: how to escape the filename

by salva (Monsignor)
on Jun 27, 2013 at 12:24 UTC ( #1041003=note: print w/ replies, xml ) Need Help??


in reply to Getting information about a remote file via SSH: how to escape the filename

Net::OpenSSH can do it for you:

use Net::OpenSSH; my $ssh = Net::OpenSSH->new($remotehost, user => $remoteuser, password + => $remotepassword); $ssh->die_on_error("unable to connect to remote host"); my ($out, $err) = $ssh->capture2(ls => '-l', $remotefile);

Another option is to use SFTP:

use Net::SFTP::Foreign; use Data::Dumper; my $sftp = Net::SFTP::Foreign->new($remotehost, user => $remoteuser, password => $r +emotepassword, autodie => 1); my $attr = $sftp->stat($remotefile); print Dumper $attr;


Comment on Re: Getting information about a remote file via SSH: how to escape the filename
Select or Download Code
Re: Getting information about a remote file via SSH: how to escape the filename
by jonadab (Parson) on Jun 27, 2013 at 14:24 UTC

    Thanks. I will definitely look into Net::OpenSSH; that seems like a good way to go for this project.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-04-17 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (449 votes), past polls