linux - spawn: How to pass arguments to spawn within an expect script? -
i have bigger bash-script stumbled problem, use ssh connect computer. 1 visited first time (always, ;) ) , therefore asks the authenticity of host '[192.168.120.170]:9022 ([192.168.120.170]:9022)' can't established. sure want continue connecting (yes/no)?
so tried answer question using additional expect/spawn script.
so have 2 files: deploy.sh
#!/bin/bash ... functions , more # call expect script first time onto target /usr/bin/expect -d -f ./deployimage_helper.exp -- -p 9022 root@192.168.120.170
deploy_helper.exp
#!/usr/bin/env expect -f set args [lrange $argv 1 end] spawn ssh {*}$args expect "the authenticity of host'[192.168.120.170]([192.168.120.170]:9022)' can't established." send "yes"
if run deploy.sh error message: invalid command name "192.168.120.170"
somehow don't spawn running ssh.
any appreciated.
edit:
changed deploy.sh line 4
set args [lrange $argv 1 end] spawn ssh {*}$args expect -re {the authenticity of .* can't established.} { send "yes" } interact
inside ""
variables , square brakets []
(evaluate command inside brackets , place result instead), expanded , evaluated. need quote square brackets \[
or use {}
instead of ""
. btw, can supress asking question (only warning showing) openssh options:
ssh -o userknownhostsfile=/dev/null -o stricthostkeychecking=no -p 9022 root@192.168.120.170
Comments
Post a Comment