linux - expect脚本中 `exit`命令后的数字是什么意思

标签 linux bash expect

我正在查看一个 expect 脚本,它有以下几行:

#some heading
send -- "some command\n" 
expect {
-re $more {
send -- " "
    exp_continue
}
">" { }
default { exit 230 }
}
# some heading
send -- "some command\n" 
expect {
-re $more {
send -- " "
    exp_continue
}
">" { }
default { exit 211 }
}    

那么exit命令后的数字“230”和“211”是什么意思。

最佳答案

数字是退出代码。它们的范围为 0-255,用于将程序成功或错误传达给可能调用该程序的其他应用程序(例如您的 shell)。

在 bash 和许多其他 shell 中,您可以使用 $? 检查最后一个程序的退出状态。退出状态为 0 表示成功,任何非 0 状态表示失败。您应该引用程序的文档以了解不同的退出代码可能意味着什么。

另请参阅 exit status 上的维基百科条目.

关于linux - expect脚本中 `exit`命令后的数字是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32498513/

相关文章:

tcl - 期待补充

linux - headless 机器中的 Dropbox

linux - 设备树编译器无法识别包含文件的 C 语法

bash - 为什么这个 echo 结构不起作用?

bash - 使用 FFmpeg 混契约(Contract)名音频和视频文件的脚本

shell - xdotool : how to wait so file opens and then execute ( xdotool windowactivate --sync $a )

linux - 混合远程期望脚本和本地 bash 命令的最佳方法是什么?

linux - Bash IFS,在函数调用中被打断

java - 如何用最少的时间在mysql中转换大约1600万行?

bash - 我如何读取 Bash 中的任何一个键?