混合shell和python脚本可能吗?
发布时间:2020-12-16 01:23:41 所属栏目:安全 来源:网络整理
导读:我发誓我以前见过这个,但现在找不到它.是否有可能让 shell脚本启动 python interpeter“mid stream”,即: #!/bin/bash#shell stuff..set +eVAR=aabbfor i in a b c; do echo $idone# same file!#!/usr/bin/env python# python would be given this fd which
我发誓我以前见过这个,但现在找不到它.是否有可能让
shell脚本启动
python interpeter“mid stream”,即:
#!/bin/bash #shell stuff.. set +e VAR=aabb for i in a b c; do echo $i done # same file! #!/usr/bin/env python # python would be given this fd which has been seek'd to this point import sys print ("xyzzy") sys.exit(0)
您可以使用此shell语法(在Unix文献中称为此文档):
#!/bin/sh echo this is a shell script python <<@@ print 'hello from Python!' @@ ‘<<'后面的标记运算符可以通过任意标识符,人们经常使用EOF(文件结尾)或EOD(文档结尾)之类的东西.如果标记开始一行,则shell将其解释为程序的输入结束. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |