Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用使用I/O间接寻址接受的代码执行shell脚本_Shell_Unix - Fatal编程技术网

使用使用I/O间接寻址接受的代码执行shell脚本

使用使用I/O间接寻址接受的代码执行shell脚本,shell,unix,Shell,Unix,我正在尝试执行这样一个脚本,接受使用间接寻址的脚本 sh <<EOT for str in `cat test` do echo $str done EOT 它给出了以下错误 sh: line 2: syntax error near unexpected token `b' sh: line 2: `b' 谁能澄清一下吗?。我的目标是像上面那样执行脚本,而不是创建一个shell脚本文件script.sh并执行它(这很好)您的外壳插入了herdeoc。要防止出现这种情况,请引用

我正在尝试执行这样一个脚本,接受使用间接寻址的脚本

sh <<EOT
for str in `cat test`
do
 echo $str
done
EOT
它给出了以下错误

sh: line 2: syntax error near unexpected token `b'
sh: line 2: `b'

谁能澄清一下吗?。我的目标是像上面那样执行脚本,而不是创建一个shell脚本文件script.sh并执行它(这很好)

您的外壳插入了herdeoc。要防止出现这种情况,请引用分隔符:

sh << 'EOT'
sh
sh << 'EOT'
sh <<EOT
for str in a
b
c
do
 echo
done
EOT