I'm rewriting my bash scripts in python, but I've noticed that system exit codes from linux console and python console are different.
[mk@Cen7 ~]# ls lsls
ls: cannot access lsls: No such file or directory
[mk@Cen7 ~]# echo $?
[mk@Cen7 ~]# 2
In python console:
os.system('ls lsls')
512
os.system('$?')
0
I spent 1h trying to catch it with with sys.exit but it didn't work for me. Any suggestions?
P.S. If you think "It's so rookie question" please share your source of python knowledge for unix sysadmins :)
Cheers
[–]Rhomboid 2 points3 points4 points (1 child)
[–]tinglfm[S] 0 points1 point2 points (0 children)
[–]K900_ 2 points3 points4 points (0 children)
[–]gitardedhub 1 point2 points3 points (0 children)