Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Enter interactive mode after executing a script

29 views
Skip to first unread message

goo...@voom.net

unread,
Oct 7, 2006, 2:36:13 PM10/7/06
to
I would like to start tclsh, execute an initialization script, and then
enter interactive mode. Of course this is exactly happens with
~/.tclshrc, but I would prefer that my application not depend on each
users' ~/.tclshrc.

With python, the -i option accomplishes this.

Is there any way to do this beyond asking users to put 'source
myInit.tcl' in their ~/.tclshrc file? If you feel that asking users to
do this is indeed the correct approach, I would be interested to hear
your opinion.

suchenwi

unread,
Oct 7, 2006, 2:42:02 PM10/7/06
to

goo...@voom.net schrieb:

> I would like to start tclsh, execute an initialization script, and then
> enter interactive mode.

As long as the Tcl interactive read-eval-print loop is not exposed at
script level (might be good :)), one can write a quick one oneself:

while 1 {
puts -nonewline "% "; flush stdout ;#-- prompt - can be more
elaborated
gets stdin line
catch $line res
puts $res
}

Christian Nassau

unread,
Oct 7, 2006, 2:49:35 PM10/7/06
to
goo...@voom.net wrote:
> I would like to start tclsh, execute an initialization script, and then
> enter interactive mode. Of course this is exactly happens with
> ~/.tclshrc, but I would prefer that my application not depend on each
> users' ~/.tclshrc.

On UNIXes you can do this with

cat myscript.tcl - | tclsh

You have to put a "set tcl_interactive 1" into your myscript.tcl to get
tclsh's usual prompt.

0 new messages