开发者

How to send data using curl from Linux command line?

开发者 https://www.devze.com 2023-03-23 11:42 出处:网络
I am trying to transmit data out of an embedded Linu开发者_开发百科x 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

I am trying to transmit data out of an embedded Linu开发者_开发百科x 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.


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>


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

wget --post-file=filetoSend 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
0

精彩评论

暂无评论...
验证码 换一张
取 消