Downloading files with wget on ESXi · random writes
Posted by jpluimers on 2021/05/31
Reminder to self to check if wget on ESXi now finally supports https downloading: [WayBack] Downloading files with wget on ESXi · random writes.
In the mean time, ESXi 6.7 Update 2 and up seems to support this; so the below workaround might only be needed for ESXi 6.7 update 1 and below.
[WayBack] VMware ESXi: help downloading large ISO – Server Fault
I will likely not do this, as by now all my ESXi boxes should have been recent enough.
I will keep the article because of the BusyBox commands section below.
If so, I might finally try and write a Python wrapper for this, as I know that Python 3 on ESXi supports https, but the ESXi BusyBox does not have a built-in cURL.
Some links and notes I might need by then:
- [WayBack] urllib.request — extensible library for opening URLs — Python v3.0.1 documentation
- [WayBack] http – Downloading a file from the command line using python – Stack Overflow
- [WayBack] Download Files with Python
- [WayBack] VMware ESXi: help downloading large ISO – Server Fault
BusyBox commands
Another cool thing in the above blog post is that it shows how to dump the BusyBox built in commands.
I ran it for ESXi 6.7 with a slight trick to get the full path (using back-ticks and escaped back-ticks) and content.
Since ESXi is BusyBox based, the commands that are in /bin
are not actually binaries, but each command is a symlink to the BusyBox binary. BusyBox then knows the original name of the command, so it can deduct what part to execute. This makes for a very space efficient storage scheme.
The various bits of the tricks to get the location of the BusyBox binary, so the --list
parameter can be passed to it:
- The
which wget
gives the full path ofwget
. - The
ls -l `which wget`
shows the full path ofwget
and the symlink target (but there is no way for ls to only show the symlink target). - The
readlink -f `which wget`
shows the full path of where/bin/wget
points to: the BusyBox binary.
The main trick consists of backtick evalution, and knowing that ls
cannot get you just the symlink target, but readlink
can:
- Backtick Grave accent – Wikipedia: Use in programming
- ln (Unix) – Wikipedia: Links
- [WayBack] linux – Find out symbolic link target via command line – Server Fault
Now the back-tick escapes, because you cannot nest back-ticks:
- The
`readlink -f \`which wget\``
executes the BusyBox binary without arguments. - The
`readlink -f \`which wget\`` --list
executes the BusyBox binary with the--list
parameter.
Note I do not like the cat --help
(see [WayBack] How do I check busybox version (from busybox)? – Unix & Linux Stack Exchange) way of getting the BusyBox version, as that gets echoed to stderr
.
This is the output:
# which wget && ls -l `which wget` && ls `readlink -f \`which wget\`` && `readlink -f \`which wget\`` && `readlink -f \`which wget\`` --list /bin/wget lrwxrwxrwx 1 root root 35 Oct 3 2018 /bin/wget -> /usr/lib/vmware/busybox/bin/busybox /usr/lib/vmware/busybox/bin/busybox BusyBox v1.22.1 (2018-07-23 19:34:44 PDT) multi-call binary. BusyBox is copyrighted by many authors between 1998-2012. Licensed under GPLv2. See source distribution for detailed copyright notices. Usage: busybox [function [arguments]...] or: busybox --list or: function [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as. Currently defined functions: [, [[, addgroup, adduser, ash, awk, basename, bunzip2, bzcat, bzip2, cat, chgrp, chmod, chown, chvt, cksum, clear, cp, crond, cut, date, dd, delgroup, deluser, diff, dirname, dnsdomainname, du, echo, egrep, eject, env, expr, false, fdisk, fgrep, find, fstrim, getty, grep, groups, gunzip, gzip, halt, head, hexdump, hostname, inetd, init, kill, ln, logger, login, ls, lzop, lzopcat, md5sum, mkdir, mkfifo, mknod, mktemp, more, mv, nohup, nslookup, od, passwd, poweroff, printf, readlink, reboot, reset, resize, rm, rmdir, sed, seq, setsid, sh, sha1sum, sha256sum, sha3sum, sha512sum, sleep, sort, stat, stty, sum, sync, tail, tar, taskset, tee, test, time, timeout, touch, true, uname, uniq, unlzop, unzip, usleep, vi, watch, wc, wget, which, who, xargs, zcat [ [[ addgroup adduser ash awk basename bunzip2 bzcat bzip2 cat chgrp chmod chown chvt cksum clear cp crond cut date dd delgroup deluser diff dirname dnsdomainname du echo egrep eject env expr false fdisk fgrep find fstrim getty grep groups gunzip gzip halt head hexdump hostname inetd init kill ln logger login ls lzop lzopcat md5sum mkdir mkfifo mknod mktemp more mv nohup nslookup od passwd poweroff printf readlink reboot reset resize rm rmdir sed seq setsid sh sha1sum sha256sum sha3sum sha512sum sleep sort stat stty sum sync tail tar taskset tee test time timeout touch true uname uniq unlzop unzip usleep vi watch wc wget which who xargs zcat
–jeroen
Leave a Reply