我正在尝试将 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)