This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Run a tcl script from a shell script

Old posts that have not been replied to for several years.
Locked
r
rbautch
Voice
Posts: 3
Joined: Sun Sep 25, 2005 1:00 am
Location: Chicago

Run a tcl script from a shell script

Post by rbautch »

I want to launch an interactive tcl script from a shell script, but when I try, it seems that the standard input channel gets messed up. For example, the following code:

Code: Select all

puts -nonewline stdout "What is your name?: " 
flush stdout set name [gets stdin]
returns the following error:

Code: Select all

error reading "file0": I/O error while executing "gets stdin"
..but the error only occurs when I launch the tcl script from a shell script. It works fine when I run it directly from bash prompt. Any ideas how to fix this?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

post your shell script
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
r
rbautch
Voice
Posts: 3
Joined: Sun Sep 25, 2005 1:00 am
Location: Chicago

Post by rbautch »

Here is the shell script, which basically just launches two tcl scripts. The first tcl script is not interactive, so it runs fine. The second tcl script chokes when I run it from this script, but works fine when I run it from bash prompt. Thanks in advance.

Code: Select all

#!/bin/sh
tivosh netconfig.tcl
tivosh setSSIDwep.tcl
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

hmm not much information there... what's tivosh? a TiVo shell? :)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
r
rbautch
Voice
Posts: 3
Joined: Sun Sep 25, 2005 1:00 am
Location: Chicago

Post by rbautch »

Tivosh is indeed TivoShell, a customized TCL installation for Tivos. I don't have a Linux PC I can test this on, so can you copy the "test" script from my original post and try to run it from bash?...Then from a simple shell script? Thanks!! :D
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

just a little note... you are aware that your script is running from sh not from bash?!
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

De Kus wrote:just a little note... you are aware that your script is running from sh not from bash?!
on Linux, /bin/sh is merely a symlink to bash
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

...and yes, it runs fine for me in both cases: when given as argument to tclsh on the shell prompt, and when tclsh is invoked from a shell script
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Re: Run a tcl script from a shell script

Post by Ofloo »

rbautch wrote:I want to launch an interactive tcl script from a shell script, but when I try, it seems that the standard input channel gets messed up. For example, the following code:

Code: Select all

puts -nonewline stdout "What is your name?: " 
flush stdout set name [gets stdin]
returns the following error:

Code: Select all

error reading "file0": I/O error while executing "gets stdin"
..but the error only occurs when I launch the tcl script from a shell script. It works fine when I run it directly from bash prompt. Any ideas how to fix this?

are you trying to do something like this ?

Code: Select all

#!/usr/local/bin/tclsh8.4
fileevent stdin readable [list [puts STDIN->[gets stdin]]]
vwait _forever_
XplaiN but think of me as stupid
Locked