14

Right now I have one-liner like this:

curl -fsSL http://git.io/vvZMn | bash

It is downloading script and passing it to bash as stdin file. I would like to run this script with additional argument print.

Maybe something like this?

curl -fsSL http://git.io/vvZMn | bash -- print

But this doesn't work.

1
  • 4
    What are you expecting print to do here? Display the commands being run? If so, try bash -x. Note: this curl | bash routine is a massive security hole; you don't get the see what will be run until your server has been pwned. Aug 26, 2016 at 23:28

2 Answers 2

19

I believe what you are looking for is the -s option. With -s, you can pass arguments to the script.

As a dummy example to illustrate this:

$ echo 'echo 1=$1' | bash -s -- Print
1=Print

Here, you can see that the script provided on stdin is given the positional parameter Print. Your script takes a -u UUID argument and that can be accommodated also:

$ echo 'echo arguments=$*' | bash -s -- -u UUID print
arguments=-u UUID print

So, in your case:

curl -fsSL http://git.io/vvZMn | bash -s -- print

Or,

curl -fsSL http://git.io/vvZMn | bash -s -- -u UUID print

As Stephen Harris pointed out, downloading a script and executing it, sight unseen, is a security concern.

0
3

If your system has /dev/stdin, you can use

$ echo 'echo 1=$1' | bash /dev/stdin print
1=print

Do not do this:

$ echo 'echo 1=$1' | bash /dev/stdin -- print
1=--

If you want to use --, do this:

$ echo 'echo 1=$1' | bash -- /dev/stdin print
1=print

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.