expect script, puting name of file in command -


i have problems expect script. when grep file need put line under , should :

/opt/ericsson/arne/bin/import.sh -f bla_bla_bla.xml -val:rall

but don't know how put file in beetween line. because when have put grep command in beetween in didn't work, maybe problem -val:rall have after? if know's how put name of file in file1

#!/usr/local/bin/expect --   set env(term) vt100 set env(shell) /bin/sh set env(home) /usr/local/bin  set password ter set dul [lindex $argv 0] set var _cus_ipsec match_max 1000 spawn ssh mashost  expect {     "assword"  {send "$password\r"} }         expect "ran@rn23"         send -- "cd /tih/opt/bla/tih/ \r"         expect "ran@rn23"         send -- "grep -il $dul * \r*"         expect "ran@rn23"         send -- "/opt/bl/arne/bin/imp.sh -f file1 -val:rall\r"         expect "ran@rn03"         send -- "/opt/bl/arne/b/imp.sh -f file1 -import\r"         expect "ran@rn23" interact 

ok, clarification, believe understand you're trying now.

what need change expect statement have after send grep command 1 capture filename. , benefit using regexp mode of expect command (-re), , possibly using parenthesis capture filename (not used in sample below). not know possible filenames can grep, need tweak below quite bit, assuming grep give single .xml file beginning "name", following:

send -- "grep -il $dul * \r*" expect -re "name.*\.xml" send -- "/opt/bl/arne/bin/imp.sh -f $expect_out(0,string) -val:rall\r" 

as suggestion, should include timeout options expect statements, , error checking, otherwise script not stop if not go expected. e.g. send if have found expected, etc.

your regexp more complicated 1 showed you, can idea. also, include exp_internal 1 somewhere near top of script good, solid debugging info on script matching (or not matching). useful test it.

let me know how goes.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -