
Jasmine
Administrator
/ Moderator
Mar 22, 2000, 6:26 AM
Post #8 of 9
(3427 views)
|
Re: Read variables from a file
[In reply to]
|
Can't Post
|
|
But ... but ... but ... Net::FTP is easy Just in case you were concerned about learning how to use yet another Perl module, here's my "cut and paste" version of using Net::FTP -- you'll just need to edit the variables, copy and paste it into your program, and that's that for that. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> ################################### # First, define the 6 variables # that's needed for Net::FTP to # to its thing. ################################### ################### # Login Information #################### $domainname = "yourdomain.com"; $username = "yourusername"; $password = "yourpassword"; #################### # Upload Information #################### $filetoupload = "/home/domain1/libs/whatever.pl"; $uploaddir = "/home/domain2/libs/"; $newfilename = "whatever.pl"; ################################### # Now, variables are defined, you # can pretty much just copy and # paste the following into your # program -- you can comment out # the confirmation messages if # you want. use Net::FTP; $ftp = Net::FTP->new($domainname); print "Connection successful.\n"; print "Attempting to log in to $domainname...\n"; $ftp->login("$username","$password") | | die "Couldn't log in using $username / $password.\n"; print "Login successful to $domainname.\n"; print "Changing directory to $uploaddir.\n"; $ftp->cwd("$uploaddir") | | die "Couldn't change to upload directory $uploaddir. $!\n"; $dir = $ftp->pwd(); # just to confirm current directory print "Successfully changed directory to $dir\n"; print "Switching to ASCII transfer mode.\n"; $ftp->ascii | | warn "Couldn't switch to ascii mode. Possible corrupted upload coming up.\n"; $ftp->put($filetoupload,$newfilename) | | die "Could not upload $filetoupload into $uploaddir/$newfilename $!\n"; print "Uploaded successful.\n"; $ftp->quit(); </pre><HR></BLOCKQUOTE> Okay ... enough fun for me this morning. Off to work I go Good luck!
|