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

来源:互联网 发布:骚扰电话黑名单数据库 编辑:程序博客网 时间:2024/06/06 00:46

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;



0 0
原创粉丝点击