Home > Archive > Unix Programming > July 2007 > create an http request from within a script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
create an http request from within a script
|
|
|
| I would like to know if it is possible to generate a http post from
our unix server. I need to post an XML file to an external url. Our
server is *not* configured as a web server, but does have http in the /
etc/services file.
Thanks,
John
| |
| Doug McIntyre 2007-07-24, 7:08 pm |
| jpw <jwilson@exeter.edu> writes:
>I would like to know if it is possible to generate a http post from
>our unix server. I need to post an XML file to an external url. Our
>server is *not* configured as a web server, but does have http in the /
>etc/services file.
Sure, what kind of scripting language?
perl/python/ruby has any number of HTTP protocol modules to use.
If you are doing sh style scripting, you probably want to look at
using curl.
(NB: /etc/services is a flat-file database just mapping name to port number.
Nothing else, it doesn't configure anything, its just informative).
| |
| Jens Thoms Toerring 2007-07-24, 7:08 pm |
| jpw <jwilson@exeter.edu> wrote:
> I would like to know if it is possible to generate a http post from
> our unix server. I need to post an XML file to an external url. Our
> server is *not* configured as a web server, but does have http in the /
> etc/services file.
/etc/service is nothing but a list of typical application-types
with certain port numbers. Having an entry in this file for a
certain port number does not indicate at all that such an appli-
cation is running on the system nor that an applcation listening
on a certain port is of the type you find in /etc/services.
If an external client needs to download a file via HTTP from
your server then you need some kind of HTTP server running
on your server. This doesn't need to be something huge. There
are lots of tiny HTTP servers you can download, and writing
one yourself is also not a large task. But HTTP isn't your
only option. If you have a ssh server running on your server
the other side could fetch the file using scp.
If, on the other hand, you need to "push" a file from your
server to an external machine then HTTP isn't a protocol you
can use for this. You must have some kind of server running
on the external machine that accepts the file. An example
would be to have an ssh server running on that machine, then
you can copy the file over to it using e.g. scp. But there
are also lots of other protocols you could use.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
| |
| shakahshakah@gmail.com 2007-07-24, 7:08 pm |
| On Jul 24, 2:39 pm, jpw <jwil...@exeter.edu> wrote:
> I would like to know if it is possible to generate a http post from
> our unix server. I need to post an XML file to an external url. Our
> server is *not* configured as a web server, but does have http in the /
> etc/services file.
>
> Thanks,
>
> John
Hard to say definitively without any details about your server, but
the answer is almost certainly yes. Several options are probably
available to you, among them:
1. open a socket to the HTTP server and format/send a HTTP POST
according
to the HTTP spec (e.g. v 1.0 at http://www.w3.org/Protocols/rfc1945/rfc1945).
You can do this via shell & netcat, C/C++, Java, or most any other
language.
2. do the same via easier-to-use tools like perl, curl, etc., if they
are available on your server (or if you can install them).
| |
| Logan Shaw 2007-07-24, 10:06 pm |
| Doug McIntyre wrote:
> (NB: /etc/services is a flat-file database just mapping name to port number.
> Nothing else, it doesn't configure anything, its just informative).
It configures things that use getservbyname(), right? Like, for example,
'getent services smtp'?
- Logan
| |
| Stephane CHAZELAS 2007-07-25, 8:06 am |
| 2007-07-24, 11:39(-07), jpw:
> I would like to know if it is possible to generate a http post from
> our unix server. I need to post an XML file to an external url. Our
> server is *not* configured as a web server, but does have http in the /
> etc/services file.
[...]
look at curl, wget, lftp commands, they may have an option for
doing that. They may not be installed on your system. If not and
you can't install them, then maybe you have link, elinks, w3m
or lynx that may be able to help you. If not, you may try perl
as long as its LWP (libwww-perl) module is installed.
If not, you may have to construct the HTTP request by hand. For
the connection, I'd use perl then.
--
Stéphane
|
|
|
|
|