hi all
i'm trying to write some test driver for our application. i'd like to create scripts which allow me to switch user and from there on talk to the application as the user i've switched to. preferably i logon as every different user (i need several users with different permissions) necessary just once and connect to the application. after that, i send commands to the application as those different users. the problem is the following: i can switch user (su) in my expect script and i can connect to the application in a different script - BUT i cannot switch user and connect as this user in the same script.
hmmm..... must be missing something there...
------------------------------------------
#!/usr/local/bin/expect --
#set environment variables
....
#switch user and connect to application
spawn su - user1
expect "password."
send "my_pwd\r"
expect "user1: "
"connect to application" <- this is the part not working
<- i've tried "source", "exec"
set user1 $spawn_id
spawn su - user2
expect "password."
send "my_pwd2\r"
expect "user2: "
etc etc etc....
#later on
set spawn_id user1
"send commands to application as user1"
set spawn_id user2
"send commands to application as user2"
---------------------------------------------
thanks for your help!
woche
i'm trying to write some test driver for our application. i'd like to create scripts which allow me to switch user and from there on talk to the application as the user i've switched to. preferably i logon as every different user (i need several users with different permissions) necessary just once and connect to the application. after that, i send commands to the application as those different users. the problem is the following: i can switch user (su) in my expect script and i can connect to the application in a different script - BUT i cannot switch user and connect as this user in the same script.
hmmm..... must be missing something there...
------------------------------------------
#!/usr/local/bin/expect --
#set environment variables
....
#switch user and connect to application
spawn su - user1
expect "password."
send "my_pwd\r"
expect "user1: "
"connect to application" <- this is the part not working
<- i've tried "source", "exec"
set user1 $spawn_id
spawn su - user2
expect "password."
send "my_pwd2\r"
expect "user2: "
etc etc etc....
#later on
set spawn_id user1
"send commands to application as user1"
set spawn_id user2
"send commands to application as user2"
---------------------------------------------
thanks for your help!
woche