Results 1 to 5 of 5
Hi ,
I have to write a bash script uses expect command to pass a password,
#!/bin/sh
#!/usr/bin/expect
the problem i'm having it's the script it's interpreted as a bash ...
- 11-13-2007 #1
expect : spawn command not found
Hi ,
I have to write a bash script uses expect command to pass a password,
#!/bin/sh
#!/usr/bin/expect
the problem i'm having it's the script it's interpreted as a bash shell and it's giving me always spwan command not found ! howerver if i remove #!/bin/sh , the whole script is interpreted as expect and all the bash variables are giving errors !
so how can i solve this problem !Linux is not only an operating system, it's a philosophy.
Archost.
- 11-13-2007 #2
How about something like this?
Code:#!/bin/sh /usr/bin/expect <<EOD place expect commands here EOD
--
Bill
Old age and treachery will overcome youth and skill.
- 11-13-2007 #3
Thanks for your reply , i think we are in the midway to get it done , but let me provide more details , i have to run cvs command and the store the output in a bash variable to use it later , the problem is this cvs command requires a password .
this get the last development version for a specific package , and i have to expect the password here, and storing the output of it in the TAG variable .Code:TAG=`cvs history -x T -la -n detectors/Tile/$CVS_PKG | grep '\:A\]$' \ | sed '/tdaq-/d' | sort --key=2,3 | sed -n '$s/^.*\[//p' | sed 's/:A\]$//'`
Really it'll be GREAT if it can be done .Linux is not only an operating system, it's a philosophy.
Archost.
- 11-13-2007 #4
I've never used cvs, and it's been quite a while since I've used expect, but I do know that you're going to have a complication because of two things.
- You capture the output of the cvs command into a shell variable, which really only works well if it's a simple piping operation, with no other interaction with the user.
- But this operation does really interact with the user, since a password is required.
I'm not sure, but the following should be very close to what you want to do. Please note the extra backslashes in color.
I haven't debugged this, but it should be very close to what you want.Code:#!/bin/sh cat > scratch1 <<EOD #!/bin/sh cvs history -x T -la -n detectors/Tile/\$CVS_PKG \ | grep '\:A\]\$' \ | sed '/tdaq-/d' \ | sort --key=2,3 \ | sed -n '\$s/^.*\[//p' \ | sed 's/:A\]\$//' \ > output.txt EOD chmod 700 scratch1 cat > scratch2 <<EOD #!/usr/bin/expect spawn ./scratch1 expect "password:" send "qwerty\r" expect eof EOD chmod 700 scratch2 ./scratch2 TAG=`cat output.txt`
It does assume, though, that cvs doesn't use standard output and standard input to get the password.--
Bill
Old age and treachery will overcome youth and skill.
- 11-13-2007 #5
Hey can you give me your mailbox address like that i can send you a gift

MANY THANKS , IT'S DONE .Linux is not only an operating system, it's a philosophy.
Archost.


