Results 1 to 4 of 4
hi, I need to switch users in a script
I'm newbee to expect
I wrote two files
1 sudo.exp, since su4098 is used as root in my laptop
Code:
#!/usr/bin/expect
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-03-2012 #1Just Joined!
- Join Date
- May 2012
- Posts
- 82
using expect to switch users in a script
hi, I need to switch users in a script
I'm newbee to expect
I wrote two files
1 sudo.exp, since su4098 is used as root in my laptop
2 test.shCode:#!/usr/bin/expect spawn su su4098 expect *Password:* send mypsw\n interact
however, in test.shCode:ls ./sudo.exp tcpdump -i wlan0 su esolve ls
when it switches to su4098,namely the root
it stops a while
and tens of seconds later, it run the password as a command
and the following commands: tcpdump, su esolve, and ls are not run
what is wrong with my scripts?
besides, how to share variables between users in a script?
thanks?
- 10-04-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,657
- 10-04-2012 #3Just Joined!
- Join Date
- May 2012
- Posts
- 82
- 10-05-2012 #4Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,657


Reply With Quote

