当 ssh 在 expect 脚本中使用交互处理时,如何在关闭 ssh 时隐藏或编辑消息
How to hide or edit a message on closure of a ssh ,when ssh was handled using interact in expect script
我有一个 expect 脚本,它使用户能够登录并在登录前打印一些特定信息,但是当我出来时它打印 "Connection to machine closed." ,我想更改正在获取 displayed.Script 保持互动 mode.Please 帮助我找到解决方案。
快速检查 ssh manual 发现 ssh 有一个 -q 选项:
-q Quiet mode. Causes most warning and diagnostic messages to be suppressed.
您可以通过 运行 man ssh
.
在您自己的系统上阅读 ssh 手册
或者,您可以将 ssh_config parameter 设置为 quiet:
LogLevel
Gives the verbosity level that is used when logging messages
from ssh(1). The possible values are: QUIET, FATAL, ERROR, INFO,
VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG
and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher
levels of verbose output.
这是发出该消息的实际代码块。可以看到在loglevel为quiet的时候被抑制了:
if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) {
snprintf(buf, sizeof buf,
"Connection to %.64s closed.\r\n", host);
buffer_append(&stderr_buffer, buf, strlen(buf));
}
我有一个 expect 脚本,它使用户能够登录并在登录前打印一些特定信息,但是当我出来时它打印 "Connection to machine closed." ,我想更改正在获取 displayed.Script 保持互动 mode.Please 帮助我找到解决方案。
快速检查 ssh manual 发现 ssh 有一个 -q 选项:
-q Quiet mode. Causes most warning and diagnostic messages to be suppressed.
您可以通过 运行 man ssh
.
或者,您可以将 ssh_config parameter 设置为 quiet:
LogLevel
Gives the verbosity level that is used when logging messages from ssh(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of verbose output.
这是发出该消息的实际代码块。可以看到在loglevel为quiet的时候被抑制了:
if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) {
snprintf(buf, sizeof buf,
"Connection to %.64s closed.\r\n", host);
buffer_append(&stderr_buffer, buf, strlen(buf));
}