linux - Expect command in bash script -
i meet problem executing expect command bash variable. have location given parameter of script , need utilize in send command via expect -c. need give " send command thinking i've ended typing , recognizing rest of command characters after close-quote. thing like:
#!/bin/bash sign=ppp expect -cd 'spawn ssh user@host expect "password:" send -- "pass\r" expect "*~>" send -- "find /local/"$sign"/ -maxdepth 1 -type d -mtime +30 |xargs rm -rfv\r" expect "*~>" send -- "exit\r"'
any thought how send variable bash expect without double-quotes? btw - cannot utilize keys ssh
you can escape '"$sign"'
:
ex:
#!/bin/bash sign=ppp expect -c 'spawn ssh tiago@localhost expect "password:" send -- "mypass\r" expect "~" send -- "echo '"$sign"'\r" expect "^ppp" send -- "exit\r"'
linux bash shell ssh expect
No comments:
Post a Comment