I have arm-based busybox (Embedded Linux) with limited binaries. How to http post or put without using curl?
Asked
Active
Viewed 5.2k times
29
-
1Check if you have `wget` it offers some similar features, but actually, you should tell us more about your project specification..PLEASE eidt your question and don't reply in comments. Also, this is likely to get closed, as it's not about solving an 'if/then/else/endif' type coding problem. The related sites here on stackExchange , http://softwarerecs.stackexchange.com OR http://unix.stackexchange.com may be better places to ask this Q. Good luck! – shellter Oct 05 '15 at 17:57
3 Answers
20
busybox
has wget
but this limited and unsuitable for posting.
You can combine busybox
with netcat
(or nc
) for achieving the result. You only need to download netcat
binaries for your platform. And here we go:
POST_PATH="/login.cgi"
HOST=199.188.1.99
BODY="Put here HTML body...."
BODY_LEN=$( echo -n "${BODY}" | wc -c )
echo -ne "POST ${POST_PATH} HTTP/1.0\r\nHost: ${HOST}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${BODY_LEN}\r\n\r\n${BODY}" | \
nc -i 3 ${HOST} 80
Based on Sending HTTP POST request with netcat post.

SergA
- 1,097
- 13
- 21
-
Update for 2022: Busybox now also has a netcat applet https://github.com/mirror/busybox/blob/master/networking/nc.c – Axel Fontaine Jan 27 '22 at 09:24
-
Update for 2023: See Sandip answer. Much easier starting with Busybox 1.35.0 – Axel Fontaine Feb 23 '23 at 13:32
-
Also update for 2023: May still need this for PUT, as the BusyBox 1.35.0 wget still only supports POST – ms-ati Aug 03 '23 at 18:00
-
But does busybox nc solution have a way to connect over SSL to an HTTPS host? – ms-ati Aug 03 '23 at 18:06
-
@ms-ati, **`nc`** can connect to server via **TCP**, but **can't** negotiate **SSL/TLS** connection. You should use **`curl`/`wget`** to work with **HTTPS**. Or more _raw_-variant is to use **OpenSSL**'s `s_clent` instead **`nc`**, for example: `echo -ne "GET /not_exist HTTP/1.0\r\n\r\n" | openssl s_client -quiet google.com:443` – SergA Aug 04 '23 at 09:38
5
i just have the same problem as you so i decided to create minimum image from alpine that do lot more than busy box and less than ubuntu https://hub.docker.com/r/prima101112/palugada
you could do curl traceroute or even vim to edit inside pods or container
or if you want to still go with busybox usually i will go
kubectl exec -it busybox -- wget {url}
kubectl exec -it busybox -- cat index.html
that command will show the response
hope this will help

prima.adi
- 121
- 2
- 4
-
This can be a great comment but not an answer. Please read the rules. – dpapadopoulos Feb 21 '19 at 05:59
-
1
Use wget --post-data "xxx" -q $URL
to make a POST request to URL with xxx
as the post data.

Sandip Bhattacharya
- 1,042
- 10
- 11