Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Send file via FTP

by Anonymous Monk
on Apr 17, 2001 at 20:25 UTC ( #73224=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi.. wondering if there is a script that will save a file generated from a perl script, and once saved to my hard drive, automagically upload it to my website. Perhaps something along the lines of sendmail.. however, the username and password issue associated with ftp presents a problem.. not sure how to handle it. Any hints pointing me in the right direction would be cool. Thanx. :) -Lisa

Replies are listed 'Best First'.
Re: Send file via FTP
by arturo (Vicar) on Apr 17, 2001 at 20:27 UTC

    Check out Net::FTP, which gives you a Perl interface into FTP. The rest I leave as an exercise for the reader =)

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: Send file via FTP
by snafu (Chaplain) on Apr 17, 2001 at 21:27 UTC
    Also, if you want to try and make the username/password thing less of an issue, use .netrc (netrc(4)) for the ftp client. Most if not all ftp clients use it. You could use a simple shell script to send everything to the remote host that way, or you can even use the username/password in the shell script itself (which is less desirable security wise).

    - Jim

Alternatives to FTP
by Dragonfly (Priest) on Apr 18, 2001 at 01:52 UTC
    If security (i.e. passwords and such) is an issue for you, might I suggest looking at the alternatives?

    SCP, an encrypted drop-in replacement for FTP, is a great alternative, and there is even a Net::SCP module that should allow you to keep using your current scripts, even if they currently rely on Net::FTP.

    To use it, you just need to make sure your web host provides Secure Shell access instead of telnet, although my suspicion is that if they are allowing FTP they are probably allowing Telnet access too, since they both allow usernames/password combinations to be passed in plain text. Anyway, I've had enough problems with FTP on my sites that I'm starting to move away from using ftpd at all, since the majority of the servers on the web are quite swiss-cheesy.

    To 'automagically' upload your file, just schedule a task using cron, to trigger your file upload script. Cron will work for task automation and scheduling, no matter if you choose to use FTP or SCP for file transfer. Good luck!

Re: Send file via FTP
by Anonymous Monk on Apr 18, 2001 at 02:16 UTC
    What you need is to look into the Net::FTP - FTP Client class. You can put together a simple script using this Module use Net::FTP; $ftp = Net::FTP->new(""); $ftp->login("anonymous","me@here.there"); $ftp->cwd("/pub"); $ftp->put("that.file"); $ftp->quit;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://73224]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2018-04-26 00:44 GMT
Find Nodes?
    Voting Booth?