in reply to Exec TCL script from Perl?

exec '/bin/sh -source blah.tcl'
?

Replies are listed 'Best First'.
Re^2: Exec TCL script from Perl?
by Anonymous Monk on Dec 08, 2008 at 16:12 UTC
    Unfortunately I need to call a tcl script first to setup my TCL environment. I found this script online but it doesn't seem to create the process so I can enter my STDIN
    use strict; use warnings; use Sockets; $wishbin = 'C:\Progra~1\TclScripts\bin\wish84.exe C:\Progra~1\bin\ +WishSetup.tcl'; die "socketpair unsuccessful: $!!\n" unless socketpair(W0,WISH84,1 +,1,0); if ($pid=fork) { print "PID: $pid\n"; select(WISH84); $| = 1; select(STDOUT); print WISH84 'source TCL_Script.tcl',"\n"; # Here is the main loop which receives and sends commands # to wish. while (<WISH84>) { chop; print "Wish sais: <$_>\n"; if (/^quit/) { print WISH84 "destroy .\n"; last; } } wait; } elsif (defined $pid) { open(STDOUT, ">&W0"); open(STDIN, ">&W0"); close(W0); select(STDOUT); $| = 1; exec "$wishbin --"; } else { die "fork error: $!\n"; }
      fork/exec would be a good model to follow on *NIX, but on Windows fork creates a new thread, not a new process.

      I guess TCL is incompatible with Perl, but, depending on the complexity, it might be easy to read the TCL and figure out environment settings in Perl before launching the main TCL script as a child process (using system).
      Or you could rewrite the setup script to use Perl then call it using do.
      Failing that, why can't the main TCL script read the TCL environment file setup?