I have url (www.blabla.web.id/proses_data.php) online. And I want to submit data to that url from my bash script. I'm using ash, bash inside OpenWRT .
I'm trying this technique,
#!/bin/sh
elinks -dump http://www.blabla.web.id/proses_data.php?data=thisisthedata
But it use GET
method. How to use POST
method?
elinks is a program for browsing the web in text mode. you may not post data throgh it.
but Linux provide beautiful tools for POST data
with this nice and little command
curl --data "param1=value1¶m2=value2" http://hostname/resource
Also POST if web response in JSON then
curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" http://someHostName/someEndpoint -d '{"id":"IDVALUE","name":"Mike"}' | grep }| python -mjson.tool
Aslo some little trick here
Add this function in php
script
function getInput() {
$fr = fopen("php://stdin", "r");
while (!feof ($fr)) {
$input .= fgets($fr);
}
fclose($fr);
return $input;
}
$takethis = getInput();
Now in bash do like
echo 22333333 | php my.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.