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
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?
-
07-08-2022 - |
質問
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
正しい解決策はありません
他のヒント
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
)
所属していません StackOverflow