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

Hi Perl Monks,

I have asked many questions in the past but I think this is my silliest one yet. I am trying to figure out how I can post a file from a command line script to a php file on another server without the use of a browser. I have done many web forms in my lifetime that does this using CGI where you press submit and all of it is taken care of. I have tried Googling all different types of phrases but to no avail. I don't even know where to begin. Can someone point me in the right direction? I don't know if this will make a difference but I would like to post an xml file.

Any suggestions would be greatly appreciated.

Perl newb

Replies are listed 'Best First'.
Re: Posting a file from command line
by Joost (Canon) on Nov 01, 2007 at 01:14 UTC
Re: Posting a file from command line
by TOD (Friar) on Nov 01, 2007 at 01:12 UTC
    if you have the LWP module(s) installed you will find a POST executable located at /usr/bin, together with a manpage.
    perl -MCPAN -e 'install LWP'
    --------------------------------
    masses are the opiate for religion.

      Probably, unless the machine in question uses a case insensitive filesystem (one of OS X's remaining big warts) and a paranoid admin didn't install the POST et al aliases because they didn't want /usr/bin/head clobbered by HEAD. However you should have lwp-request which is the same script but it uses -m method to determine what method to use rather than the name it is called as.

Re: Posting a file from command line
by leighsharpe (Monk) on Nov 01, 2007 at 05:35 UTC
    Use wget and --post-file? No perl needed </blasphemy>
Re: Posting a file from command line
by axl163 (Scribe) on Nov 01, 2007 at 15:29 UTC
    Thanks for all your suggestions. I will let you know how this turns out.
Re: Posting a file from command line
by axl163 (Scribe) on Nov 02, 2007 at 21:38 UTC
    Hi,
    I finally went with the LWP post. I had no idea it was that easy. The Mechanize package looked really cool and that is something I might use for the future. Thanks again for all your help.