• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Need help writing a script in Linux/Unix

I am trying to write a script that will connect to a telnet site that I connect to often.  I don't want to have to type in the user info and stuff over and over.  I haved tried writing a simple script with the address and login info inline, but it only connects and doesn't input the info.  Is there some "wait for response" command or something I can use?  How should I handle this?
1 Solution
You will have to write an interactive script. This can be done easily by using a very popular tool - expect. This is a freeware and is easily available. Install this tool on your system and give its path in your .profile. Then you can use the following script to connect the sysem.

set timeout -1
spawn telnet <Server-IP-Address>
expect "login"
send "<Username>\r"
expect "Password:"
send "<Password>\r"
expect "<Prompt (PS1)>"

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now