Mike
Mike

Reputation: 1481

Send message from linux terminal to some web server

I am trying to figure out how I can post a message to an http server from the linux shell. What I want is for the shell to post the message and then I can write a small php program to reroute the message to its intended recipient based on the contents and the sender. I cant seem to find a command to do this in Linux. I would really like to stick to a built in utility.

If there is a better frame work that you can think of please let me know.

Thanks

Upvotes: 2

Views: 19398

Answers (6)

Xing
Xing

Reputation: 11

--post-data does not work for me because it will report "405 Method Not Allowed"

you can actually use wget as following to send some data to http server.

wget 'http://server.com/auth?name=foo&password=bar'

Upvotes: 1

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84169

This is what curl is good at.

Upvotes: 1

sholsapp
sholsapp

Reputation: 16070

If you want to stick with built in tools use wget and refer to this SO post about posting data with wget: How to get past the login page with Wget?.

You're going to have to send your data in the post data section and format it on your server side PHP script.

Upvotes: 2

nos
nos

Reputation: 229108

The man page for wget has some examples, e.g.

wget --save-cookies cookies.txt \
  --post-data 'user=foo&password=bar' \
   http://server.com/auth.php

Upvotes: 8

Marcelo Cantos
Marcelo Cantos

Reputation: 185852

You can use curl for this purpose. Have a look at the --data* and --form options in the manpage.

Upvotes: 1

Alex Jasmin
Alex Jasmin

Reputation: 39496

curl and wget can be used for performing http requests from the shell.

You may want to use some sort of authentication and encryption mechanism to avoid abuse of the URL

Upvotes: 4

Related Questions