Am 25.01.2016 um 04:34 schrieb Justin Zamora:
> I have an Expect script that runs a command on an remote server using ssh and sudo. The script works great, with one small quirk: there is a superfluous newline at the beginning of the output. Some testing seems to indicate that this is happening as part of the "interact" command am using to catch EOF. How can I suppress this newline?
>
> Here is an example (note the blank line that I don't want).
> $ ./test.tcl
> ----- server1 -----
>
> *******************************************************************************
> * *
> * This is the message of the day. *
> * *
> *******************************************************************************
> $
>
> Here is the script I am using. As I said, it has been working for years with no problems except for the quirk with the extra newline, which I am finally getting around to trying to eliminate.
>
> #!/usr/bin/expect
>
> puts "----- server1 -----"
>
> log_user 0
>
> spawn -noecho /usr/bin/ssh -t -q -o BatchMode=yes -o StrictHostKeyChecking=no server1 /usr/bin/sudo /bin/cat motd
> expect "Password:"
> send "NotMyRealPassword\r"
#something like ( you need to check on successfull login anyway, right?)
expect \n \
TIMEOUT {puts TIMEOUT; exit
} EOF {puts EOF!; exit