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

newlisp获得bash该命令的退出状态

2015-08-15 12:51 369 查看
newlisp exec你可以运行bash命令。但如何返回状态来运行它?

特别是,我需要监控hdfs dfs -test 结果返回。经过一番摸索,我发现了一个简单的答案:

#!/usr/bin/newlisp

(set 'x (exec "hdfs dfs -test -d /user/chenshu;echo $?

"))
(println "x: " x)
(exit)

输出结果:

x: ("0")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: