In the janus project, they use curl to download and pipe a bootstrap script into bash. https://github.com/carlhuda/janus
It looks like this:
$ curl -Lo- https://bit.ly/janus-bootstrap | bash
Why would one want to use the args -Lo-
?
-o is supposed to be for output, but wouldn't that happen anyway (i.e. to stdout)?
If you've ever sat in front of a terminal, typed 'curl', pasted the URL of something you want to download, and hit enter, cool! You're going to be killing it with curl in bash scripts in no time. Here you will learn how to use curl in bash scripts and important tips and tricks for automation.
curl is a command-line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, or FILE). curl is powered by Libcurl. This tool is preferred for automation since it is designed to work without user interaction.
A pipe in Bash takes the standard output of one process and passes it as standard input into another process. Bash scripts support positional arguments that can be passed in at the command line.
In the bin folder, you will find the curl.exe file and libcurl library. You can add the bin folder to your PATH environment variable so you can execute Curl commands from anywhere. The Curl/Bash code was automatically generated for the Curl For Windows example.
It's all in the man pages:
-L
in case the page has moved (3xx response) curl will redirect the request to the new address
-o
output to a file instead of stdout (usually the screen). In your case the o
flag is redundant since the output is piped to bash (for execution) - not to a file.
The -o
is redundant, they produce the exact same output:
$ curl --silent example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-
$ curl --silent --output - example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-
They have used that syntax since that line was first introduced in 2011. You might ask Wael Nasreddine (@kalbasit on GitHub) why he did it. He is still active on that repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With