Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

I have a .cgi create a file, can I have it automatically FTPed to me or something?

by Anonymous Monk
on Jun 27, 2002 at 19:36 UTC ( #177825=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a program I call MERGE.cgi which basically combines all my shipping orders into one file (which I then import into my UPS software). Once I use MERGE.cgi to create the file, I FTP to the server and download it. Is it possible to have the MERGE.cgi automatically send the file to my local hard drive?
  • Comment on I have a .cgi create a file, can I have it automatically FTPed to me or something?

Replies are listed 'Best First'.
Re: I have a .cgi create a file, can I have it automatically FTPed to me or something?
by neilwatson (Priest) on Jun 27, 2002 at 19:47 UTC
    Yes it's possible. However, before you go any further, what is between your local hard drive and the server on which MERGE.cgi resides. There are security issues here:

    1. Your password will be stored in plain text on the server.

    2. Your password will be transmitted via plain text for all to see.

    Consider using scp or sftp that comes with the ssh package. Or consider having the server email you the file. Perhaps using mpack.

    Neil Watson
    watson-wilson.ca

Re: I have a .cgi create a file, can I have it automatically FTPed to me or something?
by Aristotle (Chancellor) on Jun 27, 2002 at 21:41 UTC
    Is there any reason you can't have the file be the output of that MERGE.cgi so you can skip all further awkwardry?

    Makeshifts last the longest.

Re: I have a .cgi create a file, can I have it automatically FTPed to me or something?
by cidaris (Friar) on Jun 27, 2002 at 22:08 UTC
    I've always found the easiest way to do this is to e-mail.
    Open sendmail as a file and put all the info you need into it. Once you close the e-mail "file" sendmail will ship it off. Depending on your server and volume of e-mail, you should get it nearly instantly.
    I have a perl script which does exactly this any time anyone views a home listing on my realty site. It e-mails me the page they looked at, their e-mail address, etc. and I never even have to connect to my server.

    Very handy.

    open(SM,"|/usr/sbin/sendmail -t"); print SM <<OUT; To: me\@me.net From: server\@yourserver.com Subject: results $msg_text OUT close(SM);
    cidaris
      Sweet! What's the address of your server? I'd love to check out your /etc/passwd file...

      Seriously, though, piping to sendmail is a big, *big* no-no, especially if it's being done through the web with user-entered data. Look at Mail::Send and a more secure way to do the same thing.

      Other than that, I'd definitely suggest e-mailing the file as a great alternative to having to ftp in manually to retrieve the file.

      scott.
        The message text that gets sent out gets run through several checkers first. In my case, if it's not plain old text, it doesn't get sent, just saved to a file, and I get e-mailed about the file's existence.

        However, I'd really like to hear about why it's a *big* big No-No.

        cidaris
What about if I have it start downloading?
by RandyL712 (Initiate) on Jun 28, 2002 at 18:51 UTC
    I thought of doing this - have the file download to me once it's been created by MERGE.cgi, using the Location: $file code. The problem? It says I don't have access to it. How do I change permissions on the fly?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://177825]
Approved by ichimunki
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-06-07 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?