LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Login script and How to automate test cases (https://www.linuxquestions.org/questions/programming-9/login-script-and-how-to-automate-test-cases-559795/)

jigneshs 06-07-2007 12:21 AM

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.

A.Thyssen 06-07-2007 01:03 AM

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.

archtoad6 06-07-2007 09:48 AM

If you decide to use ssh (as we think you should :)), then look at ssh-agent -- it's both automatic & more secure.

jigneshs 06-08-2007 02:40 PM

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.

theNbomr 06-09-2007 10:51 AM

C-Kermit has a built-in telnet client and hooks to external SSH clients, and is highly scriptable for these kinds of purposes.
--- rod.

nc3b 06-09-2007 11:00 AM

Dude you already asked this today..

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


All times are GMT -5. The time now is 07:04 PM.