|
From: ram on 24 Jun 2008 20:40 Hi All, I am running tcl version 8.4.x in a windows machine and i am trying to use the log_file command. It dose not seem to be working. The sample code is as below #! /bin/sh # -*- tcl -*- \ exec tclsh "$0" ${1+"$@"} # This is required to declare that we will use Expect package require Expect # Debugging commands used to see execution exp_internal -f rep.txt 0 set exp::winnt_debug 1 spawn cmd log_file -noappend ex3.txt send "ipconfig\r" log_file So the file ex3.txt is created but it is empty. I would have expected it to have the output of ipconfig. Please advice as to what i am missing. thanks, Ram
From: Cameron Laird on 27 Jun 2008 09:59 In article <af14f60f-c35c-4995-a52c-4b30f5bb1091(a)v1g2000pra.googlegroups.com>, ram <ramjothikumar(a)yahoo.com> wrote: >Hi All, > I am running tcl version 8.4.x in a windows machine and i am >trying to use the log_file command. It dose not seem to be working. >The sample code is as below > >#! /bin/sh ># -*- tcl -*- \ >exec tclsh "$0" ${1+"$@"} > ># This is required to declare that we will use Expect >package require Expect > ># Debugging commands used to see execution >exp_internal -f rep.txt 0 >set exp::winnt_debug 1 > >spawn cmd >log_file -noappend ex3.txt >send "ipconfig\r" >log_file > > So the file ex3.txt is created but it is empty. I would have >expected it to have the output of ipconfig. Please advice as to what i >am missing. . . . We need a page to explain the general phenomenon here; it is sooooooo common. Let's go about things this way: when your Expect script does NOT use [log_file], do you see the ipconfig(1) result you expect on the screen? I think the answer will be, "No". [log_file] only logs what there is to be displayed, and if there's nothing to display ... The crucial fact that even so many moderately-experienced Expect users miss is that Expect operates in terms of dialogues: as the programmer, you not only have to [send], but also to [expect], in order to see any results. Does <URL: http://wiki.tcl.tk/2958 > give you everything you want? If I understand your description correctly, you might be able to reduce all that programming to a single line. Please experiment with # Warning: this is not a style recommended for production. puts [open ex3.txt w] [exec ipconfig] and let us know how it works for you.
|
Pages: 1 Prev: Anyone know anyone who is hiring Tcl programmers? Next: Reading from Output |