Max13
Max13

Reputation: 921

Wget file and send it to Bash

I want to make a Bash script which has to use Wget and run its output with Bash like this:

wget -q -O - http://pastebin.com/raw.php?i=VURksJnn | bash

The pastebin file is a test script, but this commands shows me:

"Unknown command" (maybe due to new lines) and "Unexpected end of file", and I don't know why.

Am I missing something?

Upvotes: 16

Views: 20566

Answers (2)

tuxuday
tuxuday

Reputation: 3037

To start with, you save the downloaded wget'ed file locally, and run as bash filename. Because the following works for me:

cat - | bash

Upvotes: -5

sarnold
sarnold

Reputation: 104040

Your script has DOS line-endings.

If you convert the line endings to Unix line endings, it runs fine:

$ tr -d '\r' < raw.php\?i\=VURksJnn > script
$ cat script | bash
Test script
You're not root
End test
$ 

Upvotes: 8

Related Questions