我有一个从用户那里获取输入的 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.
最佳答案
可以将数据转成json格式,然后使用curl将post请求连同数据发送到网站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
关于linux - 如何从 LINUX 脚本向网站发送输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35646032/