How do I get the exit code of command and not xterm?

前端 未结 1 1424
自闭症患者
自闭症患者 2020-12-11 05:02

If I call a command (in my case another script) with xterm like so:

xterm -e sh second.sh

The value in $? after xterm returns

相关标签:
1条回答
  • 2020-12-11 05:50

    You could do something like this:

    statusfile=$(mktemp)
    xterm -e sh -c 'yourcommand; echo $? > '$statusfile
    status=$(cat $statusfile)
    rm $statusfile
    

    The exit status of yourcommand is now in variable status.

    0 讨论(0)
提交回复
热议问题