Test Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test Script
# 1  
Old 06-23-2010
Power Test Script

Hi all,
Now I want to write a test script using bash and expect script

I write a expect script as follows:
Code:
#! /usr/local/bin/expect

set command [ lindex $argv 0 ]
set password [lindex $argv 1]
eval spawn $command

switch -exact $command {
    "/create_bsim.sh" {
        expect "New Password:*"
        send "$password\r"
        expect "Re-enter new Password:*"
        send "$password\r"
        
        interact
    }
    "ssh bsim@localhost" {
        expect "Password:*"
        send "$password\r"
        
        interact
    }
    default {
        puts "Unknown script"
    exit 1
  }
}

catch "wait -i $spawn_id" reason

# return status code of spawned process
exit [ lindex $reason 3 ]


If I invoke the first command (/create_bsim.sh) , it work properly
If I want to login as another user named bsim using command ssh bsim@localhost , it can work properly. But after that, the test script will stop running.
what's the problem?

BRs
Damon

Last edited by Franklin52; 06-23-2010 at 02:20 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script test failing

Testing some old script developed by different user. #!/usr/bin/sh case "$0" in */*) cmd="$0";; *) cmd=`which "$0"`;; esac dir=`dirname "$cmd"` node="$dir/." echo $node below two simple tests are failing, I am not seeing any Control+M characters in the script file and I am not able... (4 Replies)
Discussion started by: srimitta
4 Replies

2. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

3. Shell Programming and Scripting

Backup script / Test if script is already running

Hello everyone, I have 2 questions : 1) I have a backup shell script, let's call it backup.sh, that is called every hour as a cron job. As a matter of fact a backup could last more than one hour. It mounts a NAS and then do some rsync on important directories, so really I don't want to... (2 Replies)
Discussion started by: freddie50
2 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Shell Programming and Scripting

Test Script ???

Hi can anbody explain the concept of test script with a simple test case and corresponding unix test script for the same? I need to answer this in a interview. Thanks !!! (2 Replies)
Discussion started by: skyineyes
2 Replies

7. Shell Programming and Scripting

Test Script

Hi all, i am writing a script to test if some servers are down and prompt if test positive. i used rlogin and rsh then exit but the script when run, logs into the servers and stays. pls what can i do to prevent the script from logging in i.e just check if logging in is possible? or what other... (1 Reply)
Discussion started by: sdcoms
1 Replies
Login or Register to Ask a Question