How to make expect to leave control for user?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to make expect to leave control for user?
# 1  
Old 04-21-2012
How to make expect to leave control for user?

Hello. I have several domains which are using different LDAP trees. To make life easier i wrote such script
Code:
!#/bin/bash
case $1 in
 "doman1")
  login='login1'
  password='pass1'
 "doman2")
  login='login2'
  password='pass2'
 "doman3")
  login='login3'
  password='pass3'
/usr/bin/expect -- << EXPECTEND
spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${login}@$1
expect assword: {send "\\$password\r"}
expect \\$$
interact
EXPECTEND

It is not working. I need to stay on target host, but after first command i appear on source host.
# 2  
Old 04-23-2012
I think the below may work. Not tested.
Code:
!#/bin/bash
case $1 in
 "doman1")
  login='login1'
  password='pass1'
 "doman2")
  login='login2'
  password='pass2'
 "doman3")
  login='login3'
  password='pass3'
/usr/bin/expect -- << EXPECTEND
spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${login}@$1
expect assword: "send \"$password\\\r\""
expect \\$$
interact
EXPECTEND

# 3  
Old 04-27-2012
No. Problem is with interact command. I don't know how to use it properly. Code above interact works fine. Any suggestions?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Pam.d and make difference between AD User and local user on Linux

Hello, i configured rhel linux 6 with AD directory to authorize windows users to connect on the system and it works. i have accounts with high privileges (oracle for example) if an account is created on the AD server i would to block him. I looked for how to do, for the moment all the... (3 Replies)
Discussion started by: vincenzo
3 Replies

2. Shell Programming and Scripting

Make expect exit the UNIX script in erreneous condition

Hi, I am writing a menu driven program using shell script. THe script will be collecting data by logging into the other servers and bringing back the data to home server to process it and accordingly issue commands. TO automate commands execution , I am using expect script. However I am not able... (5 Replies)
Discussion started by: ashima jain
5 Replies

3. Shell Programming and Scripting

EXPECT Bash Script Error Control

Hello Geeks once more, Thanks for all the help you have been rendering.. I have a script that depends on the output of an expect statement but sometimes the main script misbehaves which I believe is a result of SSH communication error, how can I apply an error control to know whether the... (2 Replies)
Discussion started by: infinitydon
2 Replies

4. Shell Programming and Scripting

I need to make a control panel for a Linux script

has anyone got experience using jsch? Does it give me a prompt when I run a command/ print result back to me. I need to send commands to a linux database like restart,shutdown,stop database caching etc. But in java I want to build a GUI I can use. TO call database commands. and do these... (3 Replies)
Discussion started by: Samuel12
3 Replies

5. UNIX for Dummies Questions & Answers

user control- supplementary group

What is a supplementary group and how do you make a supplementary group for members of a team? Thanks in advance. ---------- Post updated 05-10-11 at 12:09 PM ---------- Previous update was 05-09-11 at 10:08 PM ---------- anybody? (1 Reply)
Discussion started by: nlassiter
1 Replies

6. Shell Programming and Scripting

Switch to different user without expect

Hi, I have to switch to a different user and execute certain commands and then come back to the original user Ex: My id is 'usstage'. I need to switch to 'apstage', souce a script there, execute a function and then get back again to usstage. Please note that I do not have expect installed... (4 Replies)
Discussion started by: sugan
4 Replies

7. Linux

Modify expect script with control statement

Ok, so I have this script that was provided to me by one of the posters on this site. This script seems to be perfect. However, since this is a telnet script, i need to add an if then statement to it but dont know how to do it. What i want to do is to have this script spit out a certain... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

Expect control statement

I am using expect I dont know tcl but trying to use a control statement to send requests from an input file - dont know what I am doing to be honest as I dont know tcl and dont use expect too much... Any help? See below Basically I am opening a telnet session to a server which works fine... (2 Replies)
Discussion started by: frustrated1
2 Replies

9. UNIX for Advanced & Expert Users

control user password

I have two unix server ( eg. they are Server A , Server B ) and want to use LDAP to control the user profile , each of these servers have some database and application are running , assume I have setup Server A as LDAP server . Now I am not too understand the practice of it, could anyone can advise... (0 Replies)
Discussion started by: ust
0 Replies

10. Shell Programming and Scripting

User control passing parameter

there is a example: sh shell name () { echo $1 echo $2 echo $3 } echo "Enter value:" read a b c d name $a $b here permit user enter 1-4 value to the variables respectively, question is : no restrict for user input...? using only 1 variable to... (3 Replies)
Discussion started by: trynew
3 Replies
Login or Register to Ask a Question