Re: executing a configure script from a tcl scrip



On Jul 24, 5:04 am, Nicolas Castagne <casta...@xxxxxxx> wrote:
Hi folks,

I am using tcl to manage the building of the (many) projects that are
involved in my application.

Some of these projects are based on GNU autoconf / automake tools.

I am having problem to launch the configure script from tcl.

I lanch tclsh85 from msys, from the directory where the configure
script is.

Executing :
% exec configure
Produces the error :
couldn't execute "configure": no such file or directory

The best I found is something :
% exec sh -c "configure --with-tcl=e:/developpement/Tcl/lib" >@
stdout 2>@1

However :
1 - since the script is multiplatform, I'd like to get rid of the "sh -
c" command.
How can I run my configure scrip from a tcl script without executing
explicitely sh ?

2 - dunno why, but with "exec sh -c "configure ...", the shell run is
apparently more or less detached : killling the tclsh process does not
kill the child sh process
Perhaps you'd have a tip on this question ?

Thanks much,
All the best,
Nicolas

Being from the unix side if often explicitly put "./" before the
program name to make sure that some other program on the path of the
same name is not used. When working on windows I get the "can't find
file "./<program>" all the time. You will need to add . to your PATH
in order to execute the program in the current directory. I also
notice that if you do a file join using the windows drive letters and
windows separators the join will assume that you are escaping the
letters in the path rather than descending directories.
e.g. : file join c:\x\y\z program
gives : c:xyz/program

Moral of the story is to use / always and for display use [file
nativename c:/x/y/z ] => "c:\x\y\z" for
display only.

I never compiled Tcl on windows but I do know that configure scripts
are borne shell scripts so you must have a
bourne shell to run them. This means that putting "sh <scriptname>" is
cross platform. I have also found that some configure scripts fail
with bash emulating sh so I often use ksh to run the configure
scripts. One problem that irritates me to no end is that no matter
what program you run (on windows) a Command Window will popup. I
eventually found a solution ( I posted to this group but no one
replied turns out the exec man page explained it pretty well, RTFM is
good advice) . This was for a TK program so I implemented it so the
command was exec'd and the logevent handler pulled in all the output
you could easily put in a read loop in its place. It does have one
drawback in that you do not get the pid of the process so you cannot
kill or whatever the windows equivalent is . I looked at the twapi
extension for windows and it does have process kill commands; check
into that.
proc logEvent { fd logheader } {
global forever
if { ![eof $fd ] } {
set buff [ read $fd ]
if { [string length $buff ] } {

proc runCommand {logheader args } {
global forever
set bad 0
set fullpath [ auto_exe*** [lindex $args 0] ]
if { [llength $fullpath ] } {
set args [ concat $fullpath [lrange $args 1 end ] ]
}
if { [ catch {open "|$args 2>@1" "r+" } bd ] != 0 } {
set bad 1 ;
} else {
fconfigure $bd -blocking 0 -buffering full
fileevent $bd readable [list logEvent $bd $logheader ]
vwait forever
}
return $bad
}
I assume sh will be on your PATH
so running configure will be "runCommand sh configure --prefix= ...."
.