exec in Windows NT 
Author Message
 exec in Windows NT

When I attempt to execute a file with a perl or Tcl extension (.pl or
.htc) via the Tcl exec command, it will not work.  I have even tried
"exec command.exe /c myperl arg1 arg2".  That does not work either.  The
only thing I can get to work is something like "exec command.com /c
perl.exe /fullpath/myperl arg1 arg2"

The problem with the above is that you must have apriori knowledge of
the full pathname of the script.  This is a pain when the script can
reside in one of several directories in the user's PATH.

It seems the Tcl exec command on NT only recognizes .exe, .com, or .bat
files as executable.  Is there a way to make Tcl recognize the same
extensions that work well from a command prompt?  For example, from a
command prompt "myperl arg1 arg2" works well as long as the script,
myperl.pl and perl are within the PATH.  It does not work from within
Tcl via the exec command.

Unix has no problem executing a perl or Tcl script via the exec command.
Just trying to figure a way to mak the NT version behave similarly

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Fri, 07 Mar 2003 03:00:00 GMT  
 exec in Windows NT

Quote:

> When I attempt to execute a file with a perl or Tcl extension (.pl or
> .htc) via the Tcl exec command, it will not work.  I have even tried
> "exec command.exe /c myperl arg1 arg2".  That does not work either.  The
> only thing I can get to work is something like "exec command.com /c
> perl.exe /fullpath/myperl arg1 arg2"

> The problem with the above is that you must have apriori knowledge of
> the full pathname of the script.  This is a pain when the script can
> reside in one of several directories in the user's PATH.

Take a close look at the [exec] man page, which has several paragraphs
describing windows and NT behavior.  It describes exactly how [exec]
will search for programs.

The "best" way to run DOS commands on a Windows system is to use the
command processor named in the environment, like:

  exec $env(COMSPEC) /c dir

You can exploit the windows link between file types and applications by
using the start command, so you might get away with:

  exec $env(COMSPEC) /c start myperl.pl arg1 arg2

Bob
--

Mayo Foundation                                           (507) 284-2702
Rochester MN, 55905 USA   http://www.mayo.edu/sppdg/sppdg_home_page.html



Fri, 07 Mar 2003 03:00:00 GMT  
 exec in Windows NT
That is great. I do not see that the exec is necessary in Tcl.

Chang LI
Neatware



Fri, 07 Mar 2003 03:00:00 GMT  
 exec in Windows NT
Use the environment variable PATHEXT to declare any other "executable" file extension!!

My PATHEXT-definition ensures to start common script file types to be started with their
standard shell command for "open":

    PATHEXT=.COM;.EXE;.BAT;.CMD;.LNK;.TCL;.TK;.VBS;.JS;.AWK;.PY;.PYW;.PL

Bye

Martin
--
____________________________________________



Quote:
>When I attempt to execute a file with a perl or Tcl extension (.pl or
>.htc) via the Tcl exec command, it will not work.  I have even tried
>"exec command.exe /c myperl arg1 arg2".  That does not work either.  The
>only thing I can get to work is something like "exec command.com /c
>perl.exe /fullpath/myperl arg1 arg2"

>The problem with the above is that you must have apriori knowledge of
>the full pathname of the script.  This is a pain when the script can
>reside in one of several directories in the user's PATH.

>It seems the Tcl exec command on NT only recognizes .exe, .com, or .bat
>files as executable.  Is there a way to make Tcl recognize the same
>extensions that work well from a command prompt?  For example, from a
>command prompt "myperl arg1 arg2" works well as long as the script,
>myperl.pl and perl are within the PATH.  It does not work from within
>Tcl via the exec command.

>Unix has no problem executing a perl or Tcl script via the exec command.
>Just trying to figure a way to mak the NT version behave similarly

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Sat, 08 Mar 2003 06:35:47 GMT  
 exec in Windows NT
My PATHEXT has both .PL and .HTC defined, still does not work.

I defined a oneline perl script (myperl.pl) with the line: print "Hello
World\n" and a one line bat file (mybat.bat) with the line: echo "Hello
World".

I then enter Tcl.  The command: exec mybat yields: Hello World, as one
would expect.  However, the command exec myperl yields: Error: couldn't
execute "myperl": no such file or directory.  My PATH and PATHEXT are
set correctly.  Both work as expected from the command line.

VERY STRANGE!



Quote:
> Use the environment variable PATHEXT to declare any other "executable"
=
> file extension!!

> My PATHEXT-definition ensures to start common script file types to be
=
> started with their
> standard shell command for "open":

>     =
> PATHEXT=3D.COM;.EXE;.BAT;.CMD;.LNK;.TCL;.TK;.VBS;.JS;.AWK;.PY;.PYW;.PL

> Bye

> Martin
> --=20
> ____________________________________________




> >When I attempt to execute a file with a perl or Tcl extension (.pl or
> >.htc) via the Tcl exec command, it will not work.  I have even tried
> >"exec command.exe /c myperl arg1 arg2".  That does not work either.
=
> The
> >only thing I can get to work is something like "exec command.com /c
> >perl.exe /fullpath/myperl arg1 arg2"

> >The problem with the above is that you must have apriori knowledge of
> >the full pathname of the script.  This is a pain when the script can
> >reside in one of several directories in the user's PATH.

> >It seems the Tcl exec command on NT only recognizes .exe, .com, or
.bat
> >files as executable.  Is there a way to make Tcl recognize the same
> >extensions that work well from a command prompt?  For example, from a
> >command prompt "myperl arg1 arg2" works well as long as the script,
> >myperl.pl and perl are within the PATH.  It does not work from within
> >Tcl via the exec command.

> >Unix has no problem executing a perl or Tcl script via the exec =
> command.
> >Just trying to figure a way to mak the NT version behave similarly

> >Sent via Deja.com http://www.deja.com/
> >Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 09 Mar 2003 03:00:00 GMT  
 exec in Windows NT

Quote:

> My PATHEXT has both .PL and .HTC defined, still does not work.

> I defined a oneline perl script (myperl.pl) with the line: print "Hello
> World\n" and a one line bat file (mybat.bat) with the line: echo "Hello
> World".

> I then enter Tcl.  The command: exec mybat yields: Hello World, as one
> would expect.  However, the command exec myperl yields: Error: couldn't
> execute "myperl": no such file or directory.  My PATH and PATHEXT are
> set correctly.  Both work as expected from the command line.

> VERY STRANGE!

Not so strange.  Tcl's [exec] command will only attempt to add .bat,
.com, and .exe extensions on Windows platforms.  It states that pretty
clearly on the [exec] man page.

If you want to exploit features of the Windows command processor (I dare
not call it a shell), then you have to [exec $env(COMSPEC) /c myperl].

Bob
--

Mayo Foundation                                           (507) 284-2702
Rochester MN, 55905 USA   http://www.mayo.edu/sppdg/sppdg_home_page.html



Sun, 09 Mar 2003 03:00:00 GMT  
 exec in Windows NT

Quote:
> My PATHEXT has both .PL and .HTC defined, still does not work.

> I defined a oneline perl script (myperl.pl) with the line: print "Hello
> World\n" and a one line bat file (mybat.bat) with the line: echo "Hello
> World".

> I then enter Tcl.  The command: exec mybat yields: Hello World, as one
> would expect.  However, the command exec myperl yields: Error: couldn't
> execute "myperl": no such file or directory.  My PATH and PATHEXT are
> set correctly.  Both work as expected from the command line.

Have you tried

exec command /c perl.pl arg1 arg2 arg3

L

--
MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

Laurent Duperval                 "Montreal winters are an intelligence test,
                                         and we who are here have failed it."

Penguin Power!         ***Nothing I say reflects the views of my employer***



Sun, 09 Mar 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. using exec in windows nt exec on tcl scripts

2. issues with exec on Windows NT 4.0

3. exec on windows nt

4. exec under Windows NT 3.51

5. mystical exec search path, Tcl: 8.3 under Windows NT

6. exec hanging in Windows NT

7. Windows NT [exec] quoting challenge!

8. Trouble with 'exec' in windows NT

9. Exec problem under Windows NT

10. Using "exec" under Windows 95/NT

11. Compilers Windows NT or Cross Compiler SunSolaris2.5/Windows NT Fortran77

12. ANNOUNCE: Helga - ODBC,CGI,Tcl,Windows NT,Windows 95,MS Windows

 

 
Powered by phpBB® Forum Software