如何从Linux命令行使用curl发送数据?

发布于 2024-11-27 00:18:15 字数 86 浏览 2 评论 0原文

我正在尝试通过 wifi 连接从嵌入式 Linux 设备传输数据。我的设备上有curl 和wget。如何使用curl或wget将数据传输出设备?欢迎任何指点。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

姐不稀罕 2024-12-04 00:18:15

如果您只想发送(键,值)对,那么

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

但是如果您想发送一些文件,那么

curl --data-binary @<file path> <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>
风尘浪孓 2024-12-04 00:18:15

wget 中有一个“--post-file”选项:

wget --post-file=filetoSend URL

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

wget --post-file=filetoSend URL
岁月静好 2024-12-04 00:18:15

这是一个获取:curl "http://www.google.com/?hl=en&q=search"

对于帖子,您必须使用选项“-d”并指定 key=value 变量

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

陪我终i 2024-12-04 00:18:15

尝试使用 netcat,它是使用控制台发送接收数据的瑞士军刀;)。可以在此处找到一些涵盖常见用例的示例:
http://www.g- load.eu/2006/11/06/netcat-a- Couple-of-useful-examples/

发送文件:

在您的嵌入式设备上开始在端口 3333 上提供内容:

cat myfile.txt | nc -l 3333

开你的电脑开始监听端口 3333 并将数据转储到文件中:

nc <ip-of-embedded-device> 3333 > receivedData.txt

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文