terminal input in tcl

2010-09-11
2013-04-22
  • Richard Uschold

    Richard Uschold - 2010-09-11

    I'm trying to write a tcl program to get input from the terminal. This works as expected in a standard bash shell, but if I run the same program inside a mged terminal, it fails. Below is a three line program. If I source this file in an mged terminal, the second puts statement always prints "Hello World" Whatever I type at the gets statement is ignored.

    I assume I need to use some other channel then stdin, but what?

    #!/opt/local/bin/tclsh
    puts "Hello World"
    gets stdin inVar
    puts inVar==$inVar=="

    Gilligan

     
  • Richard Uschold

    Richard Uschold - 2010-10-13

    This still fails in brlcad version 7.16.10. I found it if ver 7.12, and was hoping it was corrected.

    Gilligan

     
  • Sean Morrison

    Sean Morrison - 2010-10-14

    Thanks for the report!  Perhaps worth noting, but bugs you're interested in keeping tabs of the progress on should be reported to the Bug tracker.  There, they can be reviewed, discussed, and acted upon along with providing you back with feedback as progress is made.

    Regardless, I did find a problem typing your example directly into mged and have subsequently fixed it.  The problem sourcing the script in, however, is a bit more involved so it should be reported to the tracker.  I was at least able to reproduce the problem relatively easily.

    Thanks again!

     
  • Richard Uschold

    Richard Uschold - 2010-10-14

    First, I did not realize this was a bug, I thought I just needed to change "stdin" to something else.

    Second, I had no idea sourcing the script was a different problem then the sdtin problem. Sourcing was just how I demonstrated the problem.

    Third, this failure is different on 7.16 then it was on 7.12.

    In 7.12, the "gets stdin inVar"  command allowed input from the terminal, it just did not set inVar with that data. My guess is that inVar was set from the previous value of stdout.

    in 7.16, the "gets stdin inVar"  command just gives this error message: "Error: can't rename to "execute_cmd_save": command already exists" I presume this is what you fixed?

    Gilligan

     
  • Sean Morrison

    Sean Morrison - 2010-10-14

    Sure, all completely understandable.  I was just confirming that it'd make a good bug report. :)

    Indeed, I encountered and fixed the execute_cmd_save problem in 7.16 ..  it's actually a one-line fix that you can apply to your copy if you're interested.  You can edit /usr/brlcad/share/tclscripts/mged/text.tcl and add this on line 318 after the "proc" line:
    rename execute_cmd_save ""

    Alternatively, this should make the edit for you (entered all as one line):

    perl -pi -e 's/proc execute_cmd_save {} {}/proc execute_cmd_save {} {}\n    rename execute_cmd_save ""/' /sr/brlcad/share/tclscripts/mged/text.tcl

    Cheers!
    Sean

     
  • Sean Morrison

    Sean Morrison - 2010-10-14

    Oops, that should have been /usr/brlcad .. not /sr/brlcad

     
  • Richard Uschold

    Richard Uschold - 2010-10-14

    Hmm! My path was a bit different: /usr/brlcad/share/brlcad/7.16.10/tclscripts/mged
    This did fix the new issue, and it now fails the same as ver 7.12, I submitted a bug report.

    Gilligan

     
  • Sean Morrison

    Sean Morrison - 2010-10-14

    Got the report (and can reproduce the bug), thanks!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks