How to send data using curl from Linux command line?

旧街凉风 提交于 2019-12-21 09:26:54

问题


I am trying to transmit data out of an embedded Linux device over the wifi connection. I have curl and wget on the device. How would I transmit data out of the device using curl or wget ? Any pointers welcome.


回答1:


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

wget --post-file=filetoSend URL



回答2:


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>



回答3:


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




回答4:


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


来源:https://stackoverflow.com/questions/6865146/how-to-send-data-using-curl-from-linux-command-line

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