Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Couldn't get handle : Failure at line 11,sftp a file in perl

by amchidam (Initiate)
on Mar 18, 2016 at 06:35 UTC ( [id://1158191]=note: print w/replies, xml ) Need Help??


in reply to Re: Couldn't get handle : Failure at line 11,sftp a file in perl
in thread Couldn't get handle : Failure at line 11,sftp a file in perl

Here is the code

#!/usr/bin/perl use Net::SFTP; print "Connecting...\n"; my $sftp = Net::SFTP->new('www.asd....', user=>'usead..', password=>'pass..') or die "could no +t open connection\n"; $sftp->ls("." , sub { print $_[0]->{longname}, "\n" }); my($stdout)=$sftp->status; print $stdout."\n"; print "Connected!\n"; $sftp->put("/var/tmp/prac/hi.txt",'/var') or die "...problem !..."; print "\nFinished\n";

output:

Connecting...

drwxr-xr-x 4 root root 512 Mar 25 01:33 ..

-rw-r--r-- 1 axadmin gadmin 66 Oct 26 2004 .profile

-rw-r--r-- 1 axadmin gadmin 283 Apr 26 2004 .tcshrc

-rwx------ 1 axadmin gadmin 265 Jan 28 04:48 .bash_profile

drwxr-xr-x 3 axadmin gadmin 512 Jan 28 23:55 asusmconf

0

Connected!

Couldn't get handle: Failure at sft.pl line 14

...problem !... at sft.pl line 14.

I can't able to use Net::SFTP::Foreign, as Foreign module is not available.

  • Comment on Re^2: Couldn't get handle : Failure at line 11,sftp a file in perl
  • Download Code

Replies are listed 'Best First'.
Re^3: Couldn't get handle : Failure at line 11,sftp a file in perl
by poj (Abbot) on Mar 18, 2016 at 07:51 UTC

    Assuming you have write permisions for /var try adding filename

    $sftp->put("/var/tmp/prac/hi.txt",'/var/hi.txt') or die "...problem !...";
    poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-20 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found