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.
Asked
Active
Viewed 3.5k times
8
-
yes I did. too many options. Found little confusing. – Ankur Agarwal Jul 28 '11 at 20:30
-
explain some more then. what is the "data" you want to transmit and how do you exactly need to "transmit" it? – marcelog Jul 28 '11 at 20:31
-
Data could be just a string, any string. Say want to do google search from from command line. What I mean is, I want to send some string to any server out there ( doesn't matter which one) – Ankur Agarwal Jul 28 '11 at 20:34
4 Answers
35
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>

Satyajit
- 3,839
- 1
- 19
- 14
8
there is a "--post-file" option in wget:
wget --post-file=filetoSend URL

Michał Šrajer
- 30,364
- 7
- 62
- 85
1
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

marcelog
- 7,062
- 1
- 33
- 46
-
Thanks but whats the key name for google search ? Value I think would be the thing I want to search...right ? – Ankur Agarwal Jul 28 '11 at 20:48
-
in a get request you pass the variables in the querystring. in a post, they are part of the body of the request. so in this example, the variable "q" holds the search (in this case, this will google "search"). you might want to read more about how http get & post requests work: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol for a quick introduction and: http://www.w3.org/Protocols/rfc2616/rfc2616.html for the rfc itself – marcelog Jul 28 '11 at 20:55
-
I am sorry to say that your answer is not very helpful. I know I should learn these things more. I am pressed for time and I am just looking for a quick answer, thats all. Can you just give me the command line ? – Ankur Agarwal Jul 28 '11 at 21:06
-
1abc, is this what you are looking for? `curl www.google.com/search?q=THIS_IS_THE_SEARCH_STRING` ? – Matt Jul 28 '11 at 23:15
0
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

das_weezul
- 6,082
- 2
- 28
- 33
-
I want to use wifi for data transmission. Are you suggesting I use usbnetwork or something like that to bring device and PC on the same network ? – Ankur Agarwal Jul 28 '11 at 20:53
-
No, netcat can be used over network. It doesn't matter if this network is established using ethernet or wifi. So as long as your device has joined the same network as your PC, you can send and receive data via netcat – das_weezul Jul 28 '11 at 20:59