0
Hello,

I need to create a shell script to telnet to a remote server. Perform some action and then exit from that server.

I am trying with a dummy script:
#!/bin/bash

telnet 172.11.11.21 8101<dummy.txt
exit

The dummy.txt contains the password.

The script is not working with the port number. I am getting the following error:
8101: Bad file descriptor

Please advice.
4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by eggi
0
username="myUser"
password=`cat dummy.txt`
# alternatively:
#password=$1
telnet 172.11.11.21 8101 <<EOF
    $username
    $password
    #insert command here
EOF
0

Hey There,

Your results may vary depending on what's running on the port you're connected to. For instance, I don't believe straight-up telnet (port 23) allows for non-interactive here-document scripting. In such instances, you can use other programs like Perl or, probably more easily, Expect to script out a "fake human interaction"

Best wishes,

Mike

0

Good deal :)

Just for clarity, the point I was trying to make - try that test with port 23 - if you have telnetd running on that machine :)

I'm glad you're all set !

Best wishes,

Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.