简体   繁体   中英

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?

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
$ 

To start with can you save downloaded, wgeted , file locally and run as bash filename . Coz the following works for me cat - | bash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM