Solved

Automate telnet from unix to unix

Posted on 2004-10-28
309 Views
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?
0
Question by:Cherylvan
    10 Comments
     
    LVL 48

    Expert Comment

    by:Tintin
    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?
    0
     
    LVL 38

    Expert Comment

    by:yuzh
    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;
    http:Q_21179831.html
    0
     

    Author Comment

    by:Cherylvan
    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"        
    interact          
    mget cheryl        
    close              
    exit      

    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.        
    0
     
    LVL 48

    Expert Comment

    by:Tintin
    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?

    0
     

    Author Comment

    by:Cherylvan
    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?
    0
     
    LVL 48

    Expert Comment

    by:Tintin
    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.
    0
     

    Author Comment

    by:Cherylvan
    Tintin,

    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.

    Cheryl
    0
     
    LVL 38

    Expert Comment

    by:yuzh
    For Solaris you can download expect from:
    http://sunfreeware.com/

    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)





    0
     
    LVL 48

    Accepted Solution

    by:
    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.
    0
     

    Author Comment

    by:Cherylvan
    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.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    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.
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.

    934 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now