Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-07-2007, 12:21 AM   #1
LQ Newbie
Registered: Jun 2007
Posts: 6

Rep: Reputation: 0
Login script and How to automate test cases

Hi all,

I am new to shell scripting. I am trying to write a shell script that allows me to telnet to some IP, then on that IP, it propmts me to enter username and password, and then from that IP's command prompt it exit and returns to its own command promt.

And my main purpose of using the Shell Scripting is that I want to automate few test cases. The test case is like this:

First, on unix command prompt, I go into another application. This appplication has its own set of commands, and I want to test these commands, so can I write a shell script to test these commands.

Can you tell how will the program look like for such an automation.
Old 06-07-2007, 01:03 AM   #2
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 153

Rep: Reputation: 44
Do you really need to telnet -- that is probably the most insecure network protocal!

try using ssh instead.

As for scripting. Yes you can do it. Look up Expect, as well as perl expect, and expectTK.

the main trick of these APIs is that it wraps the comminication in a psuedo-tty, so the program itself thinks it is talking to a user.

Lots more info out there if you google.
Old 06-07-2007, 09:48 AM   #3
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
If you decide to use ssh (as we think you should ), then look at ssh-agent -- it's both automatic & more secure.
Old 06-08-2007, 02:40 PM   #4
LQ Newbie
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
I want to test a program in LINUX. The program is like this:

First, on linux command prompt I type my program name to enter into my program.
like #ABC

then it asks me for user name and password, like:


then, a new prompt is returned to me, like:

Then on this promt I want to test the commands which are specific to this program, i.e.
which are commands of this program, like:


/* User created.


# <linux prompt>

The EXIT commands brings me back to the linux prompt.

Can anyone provide me the code for testing these type of commands. My aim is that program
should automatically enter into the program, take username n passwd without human intervention,
then execute commands of programs and then exit from the program and returns to linux prompt

I also want to put results in a file so that I can parse it and check whether command is
executed successfully or not.........or if there is another better way then let me know.

What can I use for this type of testing and can you please provide me a small code for it.
Old 06-09-2007, 10:51 AM   #5
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
C-Kermit has a built-in telnet client and hooks to external SSH clients, and is highly scriptable for these kinds of purposes.
--- rod.
Old 06-09-2007, 11:00 AM   #6
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Dude you already asked this today..


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to automate html proxy login thyrf Linux - Networking 3 04-29-2007 04:17 PM
Device Drivers Basics -- I want to write test cases MadAboutLinux123 Linux - Newbie 2 01-06-2007 01:39 AM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM
how to automate ssh login? Lotharster Linux - Networking 2 12-05-2005 12:54 PM
how to automate telnet login, script or something kiwibird Linux - Networking 2 11-09-2005 02:02 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration