Phi
Phi

Reputation: 514

Expect script error send: spawn id exp4 not open while executing "send "password""

I'm trying to run an expect script but I have an error:

send: spawn id exp4 not open
    while executing
"send "password"

My script is very simple:

#!/usr/bin/expect -f
#!/usr/bin/env expect
#!/usr/bin/env export
#!/bin/sh
#!/bin/bash
spawn sftp -o IdentityFile=/home/localUser/MyPrivKeys_open.ppk [email protected]
expect "sftp.gatewayEnter passphrase for key '/home2/localUser/MyPrivKeys_open.ppk':"
send "passphrase\r"
expect "sftp>"
send "cd /home/localUser/localPath \r"
expect "sftp>"
send "mget myfile.xml /home/localUser/localPath \r"
set timeout 5
interact

What I do is editing my expect script in notepad.exe but when i upload my script i have to run next commands:

dos2unix bash.sh -> converts dos file to a Unix file

chmod +x bash.sh -> gives execution permission

And finally i run my script:

./bash.sh

But after that it sends that error. It is something really weird because i have another .sh file with the same structure and i am only changing paths where i get files

I think i need some help about it.

Thanks.

Upvotes: 1

Views: 6772

Answers (1)

Phi
Phi

Reputation: 514

I have already fix it, it was an error in dos2unix command. I had to code it again over Ubuntu for avoiding to run dos2unix command.

Upvotes: 1

Related Questions