LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2013, 09:59 AM   #16
bhavin bhatia
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
expect script terminates unexpectedly


I have written the below expect script but it's not working as expected. I want the script to terminate automatically when all the commands are executed. However , the script either never terminates ( if set timeout -1 is used ) or terminates within seconds even before my commands are executed. Can someone please help ?

#!/usr/local/bin/expect

spawn su vserve
set password vserve
set PWD whoami

set cmdstr(0) "bash /apps/vpn/vserve/vserve_profile"
set cmdstr(1) "bash /apps/vpn/asap/scripts/change_loopback.sh"
set timeout -1
expect "*Password:*" {
sleep 1
send "$password\r"
send "$PWD\r"
sleep 1

for {set i 0} {$i<[array size cmdstr]} {incr i} {
send "$cmdstr($i)\r"

}

send \"exit\r\"
expect eof
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
Expect/Tcl function to login in a router. threeonethree Programming 3 11-19-2010 07:50 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM
expect/bash sk8guitar Programming 5 10-06-2009 12:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration