LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 08-24-2008, 09:15 PM   #1
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
How to call expect in shell script?


If I use #!/bin/expect,it works
Code:
#!usr/bin/expect  -f
set password my_passwd
spawn ssh my_user@my_ssh_server
expect "*password: "
send "$password\r"
interact
But when I use expect in shell script,it doesnt work
Code:
#!/bin/bash


/usr/bin/expect <<EOF
set password my_passwd
spawn ssh my_user@my_ssh_server
expect "*password: "
send "$password\r"
interact
EOF
How to use expect in shell script?
Thanks.
 
Old 08-24-2008, 09:27 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu (x86), Debian (PPC)
Posts: 3,528

Rep: Reputation: 60
Consider putting the expect script in a separate file and invoking it with the -f option.
 
Old 08-25-2008, 08:33 PM   #3
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Etch/Lenny/Squeeze
Posts: 3,485

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Doesn't work is not a correct error description.

Put this in the expect part of you script:
Code:
exp_internal 1

Then execute you script with
Code:
sh -x yourscript
You should see something which leads you quickly to the problem. If not you are able to tell us where it goes wrong.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
exec the expect command in a shell script wanghao Linux - Networking 6 11-23-2007 11:06 PM
How to combine Expect and Shell script Uday123 Programming 0 12-27-2005 09:01 AM
Shell Script call API treotan Programming 1 08-22-2005 10:59 PM
call a c program in a shell script jagman Programming 4 04-05-2005 04:58 PM
Call a shell script from php? jharper101 Programming 2 02-15-2005 12:51 AM


All times are GMT -5. The time now is 03:22 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration