I’m telnetting to a machine via a bash script. Everything works ok except that the output of the telnet session is displayed on the screen. I’d like to know how to suppress this. I can’t seem to find the right place to put /dev/null in.
I don’t want to run script.sh > /dev/null as I need to see other output from it.
expect <<EOF
set timeout 20
spawn telnet 0.0.0.0
match_max 100000
expect -exact "Trying 0.0.0.0...\r
Connected to 0.0.0.0.\r
Escape character is '^\]'.\r
\r
User name: "
send -- "user\r"
expect -exact "user\r
\r
Password: "
send -- "pass\r"
expect -exact "pass\r
send -- "commands"
send -- "exit\r"
EOF
According to the
expectman page, thelog_user 0command can be used to disable logging to stdout. This doesn’t change logging to the logfile. Similarly,log_user 1can be used to reenable stdout logging.