小编rag*_*jan的帖子

反引号或此处字符串或读取在 RHEL 8 中未按预期工作

我正在尝试将 python 脚本的输出重定向为交互式 shell 脚本的输入。

测试文件

print('Hello')
print('world')
Run Code Online (Sandbox Code Playgroud)

说 test.py 如上所述打印“Hello world”,它使用Here 字符串重定向提供给两个变量,如下所示

交互式脚本read a b <<< `python3 test.py`

这在 Rhel 8 服务器中没有按预期工作,而在 Rhel 7 中工作正常

雷尔8:

tmp> read a  b  <<< `python3 test.py`
tmp> echo $a $b
Hello
tmp> cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)
Run Code Online (Sandbox Code Playgroud)

变量b在rhel 8中为空

雷尔7:

tmp> read a  b  <<< `python3 test.py`
tmp> echo $a $b
Hello world
tmp> cat /etc/redhat-release
Red Hat Enterprise Linux …
Run Code Online (Sandbox Code Playgroud)

bash rhel io-redirection read here-string

3
推荐指数
1
解决办法
179
查看次数

标签 统计

bash ×1

here-string ×1

io-redirection ×1

read ×1

rhel ×1