I have to login to telnet using shell script, when i am logging directly, it is asking to press Ctrl c, how will i do this through shell script?

StackOverflow https://stackoverflow.com/questions/20352379

  •  07-08-2022
  •  | 
  •  

Pergunta

This is the message I received while logging in manually.

NOTE :
TO START MMC, PLEASE KEY IN "CTRL+C"
OR USE "SEND IP" COMMAND.

while I login to telnet using the following script, it is showing...

!/usr/bin/expect -f


    telnet '172.16.64.0'
    expect "COMMAND."
    send \003
    expect "USERID <"
    send "PSW001;"
    expect "PASSWORD <"
    send "PSW001;"
    interact

NOTE :
TO START MMC, PLEASE KEY IN "CTRL+C"
OR USE "SEND IP" COMMAND.

#telnet> Connection closed.
#+ expect COMMAND.
#couldn't read file "COMMAND.": no such file or directory
#+ send 003
#login.sh: send: command not found
#+ expect 'USERID <'
#couldn't read file "USERID <": no such file or directory
#+ send 'PSW001;'
#login.sh: send: command not found
#+ expect 'PASSWORD <'
#couldn't read file "PASSWORD <": no such file or directory
#+ send 'PSW001;'
#login.sh: send: command not found
#+ interact
#login.sh: interact: command not found

Nenhuma solução correta

Outras dicas

You could try using "expect" in your script to set up the connection - see here for how to do that. Once you have the connection, you can use "send \003" as per this article to send the Control-C

You can send CTRL-C with echo:

echo ^C

(To get a verbatim CTRL-C, type CTRL-V CTRL-C - and it will appear as ^C)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top