linux - 如何从 LINUX 脚本向网站发送输入

标签 linux shell curl sh ksh

我有一个从用户那里获取输入的 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/

相关文章:

r - 在 Microsoft R Open 上安装包失败

javascript - 通过 Google Apps 脚本 POST 到 Todoist API 时出现 HTTP 错误 "AUTH_CSFR_ERROR"

linux - 如何使用多个(嵌套)分隔符从文本中提取值

c++ - IMG_Load 返回 SDL_image 错误 "unsupported image format"

linux - 如果写出从1到4321的数字,数字 '5'会出现多少次?

linux - linux中文件的原子读取和截断

linux - Bash 权限被拒绝

curl - 自动上传到FTPS

Python 如何使用用户名/密码发出 curl 请求

php - 查找具有特定文本的文件并删除该文本