简体   繁体   English

wget文件并将其发送给bash

[英]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: 我想创建一个bash脚本,它必须使用wget并使用bash运行它的输出:

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. pastebin文件是一个测试脚本,但是这个命令显示:“未知命令”(可能是由于新行)和“意外的文件结束”,我不知道为什么。

Am I missing something? 我错过了什么吗?

Your script has DOS line-endings. 你的脚本有DOS行结尾。

If you convert the line endings to Unix line endings, it runs fine: 如果将行结尾转换为Unix行结尾,它运行正常:

$ 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 . 首先,您可以在本地保存下载的, wgeted文件,并以bash文件名运行。 Coz the following works for me cat - | 以下为我的作品猫 - | bash 庆典

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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