Telnet to Gogo shell works well but telnet with bash script returns connection closed by foreign host

324 Views Asked by At

I am trying to use bash script to do some works automatically with telnet ( actually to interact with Felix Gogo shell). Simply they are:

telnet localhost 11311
command 1
command 2
...

I followed these instruction:

automating telnet session using bash scripts

The script I am using is: ~/telwork.sh

echo 'open localhost 11311'
sleep 1
echo 'command 1'
sleep 1
echo 'command 2'
sleep 1
echo 'command 3'
...

Unfortunately ./telwork.sh | telnet will exist during the execution with Connection closed by foreign host. However, if I manually do the works one by one in the console, everything works well. The same problem occurs in both mac osx and rhel.

I have made some search on the internet and stackoverflow but it seems that the answers are always talk about authentication. But I can login to the Gogo shell by typing telnet localhost 11311.

Therefore I post this problem for your help. Thank you very much.

0

There are 0 best solutions below