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

Running perl scripts from tcl

1,130 views
Skip to first unread message

Bjarte Kvalheim

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
Hi there!

I have a tcl program that I use as an interface for several perl
scripts. What I want to do is to get the feedback thats written from the

perl scripts back into the a tcl text window that I have created. I have

tried with both the exec and the open command, but not succeded.

The tcl window will work as a logg window, that receives all the
information the perl scripts put out.

How can this be done. My platform is Win NT 4.0 (service pack 4).

Regards

Bjarte Kvalheim
Aladdin Software


Cameron Laird

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
In article <3871A44D...@aladdin.no>,
.
.
.
So what *is* the result when you try the simplest possible
approach, say,
set result [exec "/Program Files/Perl/bin/perl.exe myscript.pl"]
puts "Result is '$result'."
?
--

Cameron Laird <cla...@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html

Bjarte Kvalheim

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
It did a small modification and write to the text window:
set result [exec "c:/util/perl5/bin/perl.exe myscript.pl"]
.text insert end "$result"

With that command wish says:
couldn't execute "c:\util\perl5\bin\perl.exe myscript.pl": invalid argument

This seems weird to me. I mean, it should be possible to use arguments to a
program thats called withe exec? For me is seems that exec believes that
myscript.pl is a argument to exec itself.

Then when trying with open I use:

set command "|c:/util/perl5/bin/perl.exe myscript.pl"
set result [catch {open "$command"}]
.text insert end "$result"

$result returns 0

without catch:
set result [open "$command"]
$result is: file1188fc0

Regards

Bjarte Kvalheim
Aladdin Software

Tore Morkemo

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
Bjarte Kvalheim <bja...@aladdin.no> writes:

> It did a small modification and write to the text window:
> set result [exec "c:/util/perl5/bin/perl.exe myscript.pl"]
> .text insert end "$result"
>
> With that command wish says:
> couldn't execute "c:\util\perl5\bin\perl.exe myscript.pl": invalid argument
>
> This seems weird to me. I mean, it should be possible to use arguments to a
> program thats called withe exec? For me is seems that exec believes that
> myscript.pl is a argument to exec itself.

Try:

set result [exec c:/util/perl5/bin/perl.exe myscript.pl]
.text insert end "$result"

exec the args as multiple arguments, not as one argument.


--
Tore Morkemo

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tore Morkemo, Bibliotek-Systemer A/S, Box 2093 Stubberød, 3271 Larvik, Norway
______ http://www.bibsyst.no/ansatte/tore/ e-post: to...@bibsyst.no ______

Bjarte Kvalheim

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
That did the trick!

I also found another way by using "open" and "fileevent".
For those of you that finds this interesting here's the code:

set command "c:/util/perl5/bin/perl.exe myscript.pl"

if [catch {open "|$command "} input] {
# error message
.text insert end $input\n
} else {
fileevent $input readable [list output $input]
.text insert end $command\n
}

proc output {pipe} {
if [eof $pipe] {
catch {close $pipe}
return
}
gets $pipe line
.text insert end $line\n

0 new messages