I need to transfer some 100 files into my remote directory in to the other machine..And i have develop a script that could done my task !...This script will read all the content of files in the local directory then transfered it one-by-one. After transferd one file, these file will be removed..And the provcess will go on until all the files are transfered and remove successfull ..Below is my script...
use Net::SSH::Perl; use Net::SFTP; $host = '***.***.***.***'; $username = '****'; $passwd = '****'; $remote_path = '/home/roime/'; $local_path = '/flow/flow'; chdir $local_path or die "Could Not Change Dir To $local_path!"; opendir(FILE, $local_path) || die("Cannot open directory"); @files=readdir(FILE); closedir(FILE); foreach $file(@files) { next if(-d $file); next if($file eq ".flow"); { $sftp=Net::SFTP->new($host, user => $username, password => $passwd, debug => 0) or die "Cannot connect to $host:$@"; $sftp->put("$file", "$remote_path") or die "...problem !..."; $sftp->ls($remote_path); unlink("$local_path$file") or die "having trouble deleting $file:$!";; print "$file deleted success....\n"; } } sub usage { my($name) = $0; $name =~ s/.*\///; print STDERR "Usage: $name <host> <username> <passwd> <remote_path> <l +ocal_path>\n"; exit; }
After i execute it, i receive this error message and I really need somebody opinion about this error...Thanks... Couldn't get handle: Failure at /usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 168. Couldn't write to remote file: Failure at /usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 263. Couldn't close file: No such file or directory at /usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 203. ...problem !... at rput.pl line 40.

In reply to Net::SFTP In Linux ....... Error by kicap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.