Expect/TCL:Cannot read the script file from GUI
Posted by skumar003 (skumar003), 5 February 2003I have this telnet application which runs this way.
at the command line >execute host scriptfile.
Now I am trying to do the same thing from the GUI at the click of a button.
FRom the GUI code I (function run) I call execute & soon after If i say source the script file it runs fine. But If I specify the script file at the textbox on the GUI it cannot read the file. Connection to host is not a problem. It does not read the script file hence ultimate goal is not met.
I am not sure How clear I am being here. Can U please suggest.
Posted by admin (Graham Ellis), 6 February 2003Questions
Have you checked that the file name that you get back from the GUI text entry box contains the text that you expect, or could it have an extra space or something in it?
Have you checked that your original script runs under wish just as it did under Tcl - in other words, is the problem wish related, or related to the variables and code you have written?
Have you considered updateideltasks to ensure that the GUI gets a lookin - is it possible that your appliaction is running, but you're just not seeing the answers>
I would proceed with further testing on this one, dividing the problem down until it became clearer what was going on ... which in turn should point you towards a solution
Posted by skumar003 (skumar003), 6 February 2003After fixing a few things Now I get the following error.
error reading "file7": illegal operation on a directory
I rerun & Ii get the same error with "file9" and run again thefile becomes "file11" and so on......
I know I am not passing "file" anywhere in the code. This is some internal error flag.
Can U tell what is going on?
Posted by skumar003 (skumar003), 7 February 2003The problem is with an extra space at the input(textbox). hence it cannot read the file. Can U suggest why this extra space is created at the text box and it is getting passed with the space.
While typing in the text box U can begin without any space, but as soon as mouse click is done to execute the first letter shifts by 1 space.
Posted by admin (Graham Ellis), 7 February 2003I expect that the extra space is added by a command, configuration, event, or textvariable in your code. Tk uses events; when an event occurs, the code that's programmed to the even runs without you making any explicit call.
"Quick and dirty" idea .... use string trim to get rid of the excess space - NOT a good solution in the longer term but it will prove if an extra space truely is causing your problem
You also asked about file9 file11 and things like that. Not sure if things have moved on for you now, but in case they haven't (or in case others are interested ....)
When you open a file, it returns a "channel" which you save into a variable:
set fchan [open myfile.txt r]
The fchan variable contains a "handle" through which you can access the file in commands like read and gets ... you really shouldn't use the contents for other purposes. However, all variables in Tcl are text strings and so even a channel is a string of text, and it happens often to be the word file followed by a number. So the message you saw tells me that you're looking at file channels as if they were normal variables. The fact that the number seems to be increasing tells me that you're possibly not closing your files properly, or that you're intentionally opening a lot of files at the same time.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho