Linux wget 文件并将其发送到 bash

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10409539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:07:39  来源:igfitidea点击:

wget file and send it to bash

linuxbashpipewgetpipeline

提问by Max13

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?

我错过了什么吗?

采纳答案by sarnold

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
$ 

回答by tuxuday

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

首先,您可以将下载的wgeted文件保存在本地并作为bash filename运行。因为以下对我有用cat - | 猛击