开发者

Send message from linux terminal to some web server

开发者 https://www.devze.com 2023-01-10 10:52 出处:网络
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 re

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


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


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


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.


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


This is what curl is good at.


--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'
0

精彩评论

暂无评论...
验证码 换一张
取 消