我有一个从用户那里获取输入的shell脚本,我需要将该输入提供给网站。例如
#!/bin/sh
echo -n "Enter Your name > "
read name
echo -n "Enter Your age > "
read age
echo -n "Enter your marks > "
read marks
# now all these 3 inputs have to be feed automatically to a website (e.g.abc.mydomain.com) which has the data field to take the input.
答案 0 :(得分:2)
您可以将数据转换为json格式,然后使用curl将帖子请求发送到包含数据的网站Url。
#!/bin/sh
echo -n "Enter Your name > "
read name
echo -n "Enter Your age > "
read age
echo -n "Enter your marks > "
read marks
curl -H "Content-Type: application/json" -d "{\"name\" : \"$name\", \"age\" : \"$age\", \"marks\" : \"$marks\"}" http://abc.mydomain.com