[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Automate telnet from unix to unix

Posted on 2004-10-28
Medium Priority
Last Modified: 2013-12-26
I am on a unix box and have a script that is being executed in a program (the username and password will change depending on the program).  Because of security reasons I am restricted to telnet.  I have checked all the solutions in here and the send & expect commands will not work on my machine.  Are there any other options open to me?
Question by:Cherylvan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
LVL 48

Expert Comment

ID: 12438479
How can security reasons restrict you to telnet?  Do you mean as in "our environment doesn't care about security, that's why we have to use telnet"?

Why won't expect work on your machine?  Is it installed?  Are you getting errors?

Can you use ssh?
LVL 38

Expert Comment

ID: 12440277
telnet is insecure (plain text passwork), a sniffer can catch your password, consider use
secure shell.

If you are inside a secure network (or you don't care about security), then have a look at;

Author Comment

ID: 12443523
I am inside a secure network in what they call a 'red zone'.  The code that is in my program is:
unix silent value(search("tcp-connect.sh") + " " + address + " " +
p-word + " " + p-user).                                          

tcp-connect.sh contains the following:
telnet $1 << exit  
expect "login:"    
send "$3\n"        
expect "ssword:"  
send "$2\r"        
mget cheryl        

Please don't laugh at my code, I am totally unfamiliar with telnet using scripts.  When I execute my code, it will connect to the other unix box and the login prompt will come up but it won't allow me to enter anything.  If I remove the << exit from the first line, it will let me type in the login and password but won't do anything else.        
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 48

Expert Comment

ID: 12454571
What you have there is a confusion of scripting languages.

Your script is a combination of shell, expect and FTP.

The "expect" and "send" are the nuts and bolts of the expect scripting language, which is ideal for these types of interactive processes.

"Interact", "mget", "close" are FTP commands, so they certainly aren't going to work with a telnet session.

Do you have expect installed on your server?

Are you just wanting to retrieve a file or run a particular command on the remote server?


Author Comment

ID: 12462719
The interact, mget and close were just left in there from a copy of an old ftp shell script.  I am currently just trying to do a test by getting to another box without entering a password or login and retrieve a file with my name and bring it back.  We don't have the equipment in place at the moment to do much else but what I am ultimately trying to do is on the other box, when you login with a specific login and password, I will send it a specific command which will cause the other box to run a 'polling' program which will create a file that I will bring back.  I thought expect and send were part of telnet, is there something else I need to install to use these commands within telnet?
LVL 48

Expert Comment

ID: 12466634
Expect is a seperate package and has no relationship to telnet.

What Unix flavour are you running?

It's a real shame your "secure" network doesn't won't/can't use a secure mechanism like ssh, as this would make the task *very* easy as well as being secure.

Author Comment

ID: 12466912

I'm using the Sun-Solaris type unix.  I can try and see if I can use ssh.  I know there are some sites that I am to telnet to and some sites that I'm going to have to dial into.  I'm not sure of the reason why, I think its because of the equipment out at the sites.  To use ssh, do you have to have that on both sites?  Could that be why they want me to use telnet, or could it just be because they don't know any better?  I apologize for all the stupid questions, and I really do appreciate your helping me.

LVL 38

Expert Comment

ID: 12469048
For Solaris you can download expect from:

Please remember to install the depandences as well.

You script http:#12443523 will not work, as Tintin pointed out in http:#12454571

If you still want to use expect, you can use "autoexect" to create an expect script
and then modify it.

man autoexpect
to learn more details.

If you need more help on expect script, please post the script created by "autoexpect"
we'll help you out.

Since you don't worry about security, you can try my suggestion in http:#12440277
(see the link, pay attention to my version of telnet script)

LVL 48

Accepted Solution

Tintin earned 2000 total points
ID: 12469186
If you have Solaris 9 or 10, then you will already have ssh installed on the server.  If you are using an older Solaris version, it may still be installed, usually in /usr/local/bin/ssh

ssh is very much like telnet in that you need a client on your local machine and a server on the remote machine.

If ssh is not feasible, then install expect (if not already installed) as per yuzh's instructions.

Author Comment

ID: 12472267
I'm going to give the ssh a try.  Trying to get expect installed on the machine would be like pulling teeth.  Where I am at, just to get a bug fixed installed you practically have to get the approval of the president of the company (who could care less) before installing it.  Thanks for sticking with me.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question