相关疑难解决方法(0)

如何将内联(heredoc may?)python脚本插入bash stdin/stdout流式传输管道

我最近在python中做了相当多的工作,并希望能够使用它的功能而不是shell/bash内置/ shell脚本.

所以对于像这样的shell管道:

echo -e "Line One\nLine Two\nLine Three" | (cat<<-HERE | python
import sys
print 'stdout hi'
for line in sys.stdin.readlines():
  print ('stdout hi on line: %s\n' %line)
HERE
) | tee -a tee.out
Run Code Online (Sandbox Code Playgroud)

所有打印的都是"stdout hi"

需要修复什么?

谢谢!

python bash redirect heredoc

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

标签 统计

bash ×1

heredoc ×1

python ×1

redirect ×1