I have put together a small test FTP code to test before moving it into my main program. I have research many sites that when I transfer the code over, it runs, but no results. Tried using the "die" portions to display messages, but I don't understand where the messages are going. I am assuming that my entries are correct. Any proofing of the code would help greatly. The "put" is not working, but may not be the problem. Also, the only error message I receive is "Bad remote filename....."
#!/usr/bin/perl
#
use strict ;
use warnings ;
use Net::FTP ;
my $tempdir = "/ccifas/tempifas/AU" ;
my $ftp ;
my $hostname = "ftpsrv" ;
my $username = "user" ;
my $password = "passwd#" ;
my $home = "download/targetdir" ;
my $lsfiles = "/ccifas/script_devl/lsfiles" ;
my @array ;
my $f ;
my $pwd ;
system ("cd $tempdir;ls sudolog* > $lsfiles") ;
open(SDfiles, "$lsfiles" ) or
die "Cannot open the file $!\n" ;
@array = <SDfiles> ;
close SDfiles ;
$ftp = Net::FTP->new($hostname)
or die "Cannot connect to host", $ftp->message ;
$ftp->login($username, $password)
or die "Cannot login to host", $ftp->message ;
$ftp->cwd($home)
or die "Cannot change working directory ", $ftp->message ;
$ftp->dir($home)
or die "Cannot produce the directory listing ", $ftp->message ;
foreach $f(@array)
{
$ftp->put($f) ;
or die "Cannot issue put command to host ", $ftp->message ;
}
$ftp->quit ;
exit ;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.