您的位置:首页 > 运维架构 > Shell

如何获取shell函数的返回值及shell命令的返回值?

2015-04-20 22:55 405 查看
Python 获取shell脚本执行的返回结果
http://songpengfei.iteye.com/blog/1701617 http://blog.csdn.net/duan19056/article/details/41277869
1.Python 获取shell脚本执行的返回结果

import subprocess

p = subprocess.Popen('./test.sh',stdout=subprocess.PIPE)

output=p.stdout.readlines()

print output

2.如何获取shell函数的返回值及shell命令的返回值?

#!/bin/sh

info()

{

cat jlb.sh

}

res=`info`

echo "state: "$?

echo "res: "${res}

show partiones $tableName;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐