wget file and send it to bash

Max13 picture Max13 · May 2, 2012 · Viewed 12.1k times · Source

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?

Answer

sarnold picture sarnold · May 2, 2012

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
$