How to send data using curl from Linux command line?

こ雲淡風輕ζ 提交于 2019-12-04 03:35:53

there is a "--post-file" option in wget:

wget --post-file=filetoSend URL

If it is only (key,value) pairs that you want to send then

curl -d key1=value1 -d key2=value2 <URL>

But if it is some file that you want to send then

curl --data-binary @<file path> <URL>

this is a get: curl "http://www.google.com/?hl=en&q=search"

for a post you have to use the option "-d" and specify the key=value variables

Try netcat, the swiss-army-knife for sending receiving data using the console ;). Some examples covering common use-cases can be found here: http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/

Sending a file:

On your embedded device start serving content on port 3333:

cat myfile.txt | nc -l 3333

On your PC start listening on port 3333 and dump data into a file:

nc <ip-of-embedded-device> 3333 > receivedData.txt
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!