I'm a newbie and this is my attempt at writing a transportable subroutine that will FTP a file to a remote location. I couldn't figure out how to check for errors on the remote host, so anyone that wants to help me out, please do so ...
############################################################
# FTP_FILE - Send a file to FTP host
# Requires: use Net::FTP; # Perl module for FTP access
# Arguments: $sendFile - file to be sent (full path)
# $name - file to be named on remote server
# $host - FTP host name (ftp.japh.org)
# $user - FTP login user name
# $pass - FTP login password
# Returns: none
############################################################
sub ftp_file {
local ($sendFile, $name, $host, $user, $pass) = @_; # Pass file
+name to send
$ftp = Net::FTP->new($host); # Open the host
$ftp->login($user,$pass); # Username and password
$ftp->put($sendFile, $name); # Send the file, rename
$ftp->quit; # Quit
}
####################### END SUBROUTINE #####################
In reply to Simple FTP
by rHOnDO
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.