Below is the output, followed by the script when it is run.
Name "main::path2" used only once: possible typo at transfer.pl line 38.
Net::FTP>>> Net::FTP(2.75)
Net::FTP>>> Exporter(5.58)
Net::FTP>>> Net::Cmd(2.26)
Net::FTP>>> IO::Socket::INET(1.27)
Net::FTP>>> IO::Socket(1.28)
Net::FTP>>> IO::Handle(1.24)
Net::FTP=GLOB(0x180bc60)<<< 220 unixs1.cis.pitt.edu FTP server ready.
Connected!
Net::FTP=GLOB(0x180bc60)>>> user mcs2
Net::FTP=GLOB(0x180bc60)<<< 331 Password required for mcs2.
Net::FTP=GLOB(0x180bc60)>>> PASS ....
Net::FTP=GLOB(0x180bc60)<<< 230 User mcs2 logged in.
Login successful
Net::FTP=GLOB(0x180bc60)>>> CWD ./public/html/
Net::FTP=GLOB(0x180bc60)<<< 250 CWD command successful.
Net::FTP=GLOB(0x180bc60)>>> PWD
Net::FTP=GLOB(0x180bc60)<<< 257
"/afs/pitt.edu/home/m/c/mcs2/public/html" is current directory.
pwd = /afs/pitt.edu/home/m/c/mcs2/public/html
Net::FTP=GLOB(0x180bc60)>>> HELP PUT
Net::FTP=GLOB(0x180bc60)<<< 502 Unknown command PUT.
Supported = 0
Net::FTP=GLOB(0x180bc60)>>> PORT 10,0,1,196,207,163
Net::FTP=GLOB(0x180bc60)<<< 502 Illegal PORT Command
Could not send file!
#################################################
#!/usr/bin/perl -w
#this library is needed for the transfer
use Net::FTP;
#declares your host and creates your ftp object
$host='unixs.cis.pitt.edu';
$ftp=Net::FTP->new($host,Timeout=>240,Debug=>1,Passive=>0, Port=>21) or die "Could not create FTP object!\n\n";
print "Connected!\n";
#THIS IS THE LOGIN SECTION, REPLACE $uname AND $pwd WITH EITHER A USERNAME
# AND PASSWORD, OR DEFINE THE VARIABLES YOURSELF IN THE LINES BEFORE
($uname, $pwd) = get_info();
$ftp->login($uname,$pwd) or die "Cannot login to $host!\n\n";
print "Login successful\n";
#this line will change to whichever directory you need
$dir = "./public/html/";
$ftp->cwd($dir) or die "Unable to switch directories!\n\n";
$pwd = $ftp->pwd();
print "pwd = $pwd\n";
$test = $ftp->supported("put");
print "Supported = $test\n";
#@files = $ftp->dir();
#print "Files = $files[0]\n";
#uploads the file, absolute path names required.
#path1 is the file path, path2 is the location on the remote host
$path1 = "test.html";
$path2 = "./test.html";
#$path2 = "/afs/pitt.edu/home/m/c/mcs2/public/html/test.html";
$ftp->stor($path1) or die "Could not send file!\n\n";
print "File transferred!\n";
#quits the connection
$ftp->quit or die "Unable to close the connection?\n\n";
print "Finished!\n";
exit(0);
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.