![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling expect scripts from other expect scripts | seva | Shell Programming and Scripting | 0 | 04-03-2008 10:45 AM |
| tcl/expect | calsum | Shell Programming and Scripting | 7 | 03-25-2008 10:23 PM |
| Expect/Tcl help? | earnstaf | UNIX for Dummies Questions & Answers | 2 | 07-26-2007 07:01 AM |
| Expect and auto expect command | arun_v | Shell Programming and Scripting | 0 | 03-29-2006 04:31 AM |
| Expect with tcl/tk | sanjustudy | Shell Programming and Scripting | 0 | 10-10-2005 02:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
expect: \\\[
hi all. i have a little problem:
i read the following from a file with gets blabla;\\\[;blabla2 my script: snip while {[gets $input line] >= 0} { set y 0 puts $logfile "line = $line" foreach cel [split $line ";"] { set filedata($x,$y) $cel incr y puts $logfile $cel } incr x } snip now when i puts the cells i expect blabla \[ blabla but i get blabla \\\[ blabla when i do puts "\\\[" directly i get \[ also when i do set mytest "\\\["; puts $mytest whats going on? thanks for the help! david |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
It is really very interesting issue.
Can you paste here all your code, especially part when you read input ale place it in variable "input". From my experience version of expect can play role also. Regards Sebastian |
|
#3
|
|||
|
|||
|
try this: make an input.txt with \\\[ and run this script. it expects an argument which it uses for "expect". it then prints the argument, global $myexp and the line read from the file in da.log.
you can take out the send/expect part. #!/usr/bin/expect -f # set logfile [open "da.log" w] set myarg [lindex $argv 0] set myexp "\\\[" set filename "input.txt" set input [open $filename "r"] gets $input line puts $logfile "from file: = $line" close $input proc do_it { exp } { global logfile puts $logfile "do_it: expecting $exp" send -- "ls\r" expect { timeout { puts "timed out!!" } $exp } } puts $logfile "myexp:$myexp and argument:$myarg" set timeout 5 spawn $env(SHELL) match_max 100000 do_it $myarg |
|
#4
|
|||
|
|||
|
simplified:
#!/usr/bin/expect -f # set myarg [lindex $argv 0] set myexp "\\\[" set filename "input.txt" set input [open $filename "r"] gets $input line string trim $line "\n" puts "from file:$line" puts "myexp:$myexp" puts "argument:$myarg" close $input input.txt: \\\[ when you run this you get: $ ./script.exp \\\[ from file:\\\[ myexp:\[ argument:\[ why doesnt it evaluate the \\\[ from the file properly ??? trimmnig the newline char doesnt make a difference |
|
#5
|
|||
|
|||
|
I think that question is not 'why doesn't it evaluate from file properly' but 'why it evaluate content of variable'.
Please look at this code: Code:
#!/usr/local/bin/expect -f
log_file -noappend expect.log
exp_internal 1
set myarg [lindex $argv 0]
set myexp {\\\[}
set filename "input.txt"
set input [open $filename "r"]
gets $input line
string trim $line "\n"
puts "myexp:$myexp"
puts "argument:$myarg"
while {[gets $input line]} {
puts "from file: = $line"
}
close $input
Code:
blabla \[ blabla but i get blabla \\\[ blabla Code:
myexp:\\\[ argument:\[ from file: = \[ from file: = blabla from file: = but i get from file: = blabla from file: = \\\[ from file: = blabla malyska@prov01$ expect.exp2.sh '\\\[' myexp:\\\[ argument:\\\[ from file: = \[ from file: = blabla from file: = but i get from file: = blabla from file: = \\\[ from file: = blabla Similar with input to script. If you don't use some marks as '' or "" shell will evaluate it before putting it script. |
|
#6
|
|||
|
|||
|
thanks! that makes sense.
sorry for the slow reply. was out of town unexpectedly. |
|||
| Google The UNIX and Linux Forums |