LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-07-2007, 12:21 AM   #1
jigneshs
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
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Posts: 119

Rep: Reputation: 32
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
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 230Reputation: 230Reputation: 230
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
jigneshs
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:

USERNAME:
PASSWORD:

then, a new prompt is returned to me, like:
[ABC]:

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:

[ABC]: CREATEUSER: js

/* User created.

[ABC] EXIT;

# <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
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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
nc3b
Member
 
Registered: Aug 2005
Posts: 330

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

http://en.wikipedia.org/wiki/Expect
 
  


Reply


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


All times are GMT -5. The time now is 12:41 AM.

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