This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Running Windows scripts & PATHEXT


On Mon, 30 Aug 2004, Andrew DeFaria wrote:

> Being in a Windows environment is made a lot more palatable with Cygwin
> - we all know this. But we often face others who don't know, understand
> or want to use/learn Cygwin or who want what we might develop in Cygwin
> available for others who don't have Cygwin.  As such I've been writing
> some Visual Basic (ick! But I'm getting used to it...) and cmd scripts.
>
> Now one problem is that I write a script intending for it to have
> stdin/stderr connected to a terminal. But by default vbs files are
> executed by wscript and calls to WScript.Echo pop up a message box for
> each call. However I can execute cscript to have it run "normally"
> writing to stdout. Now cscript display ugly logo info which can be
> suppressed by using /nologo. So I want an invocation of myscript.vbs to
> run cscript /nologo myscript.vbs. I think I can do that by making the
> appropriate registry entries but I still have to execute at least
> myscript.vbs.
>
> I've also made a Perl script file type and have added .pl to the PATHEXT
> variable so that I can invoke a Perl script such as myscript.pl simply
> by typing myscript (in cmd but not in bash - in bash I need to specify
> myscript.pl).
>
> So it seems that bash does not take into account the PATHEXT variable
> when searching for executables. Now I know that PATHEXT is very
> Window'ish and bash need not support it but perhaps Cygwin's bash does
> somehow and I merely need to configure it correctly? I"m looking to be
> able to simply type myscript and have it run myscript.pl (or
> myscript.cmd or myscript.vbs - I guess I oughta ask: How would it
> determine which one to run in the face of multiple scripts? I guess
> order of the PATHEXT?)

Ugh.  I fully agree with CGF - the "hide the extension" business is ugly,
counterproductive, and should not be used.

Having said that, is there any reason why

$ ln -s myscript.pl myscript && chmod a+x myscript.pl

doesn't do the trick?  AFAIK, Windows doesn't attempt to execute files
with no extension, so it won't interfere with CMD, and will allow bash to
execute myscript.pl by typing "myscript"...

The situation with VB scripts is harder.  I'd go for something like

$ cat > myscript << EOF && chmod a+x myscript
#!/bin/bash
cscript /nologo myscript.vbs
EOF

if you wanted to run "myscript.vbs" by just typing "myscript".  FWIW, if
there were a way to get Visual Basic to ignore the shebang line at the
top, there's a way of specifying the right script interpreter, too, so
that you could run "myscript.vbs" directly, but I guess VB will punt on
that, so I won't go into details.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]