CygWin - PATH finds "myscript.sh" but not "myscript"

CygWin - PATH finds "myscript.sh" but not "myscript"

Post by Mark Prente » Sat, 20 Jul 2002 07:43:46



Hi, I'm new to CygWin,  I've written a script called "myscript.sh" and
placed it in a directory in the PATH.  I am able to run the script from
anywhere using the name "myscript.sh"......but I would also like to be able
to run it by just typing "myscript" without the ".sh."

I'm pretty sure this is possible because when working with MKS Toolkit,
which uses a Korn Shell, it worked that way out of the box.  CygWin seems to
have some of this functionality because ".exe" files will work like this.
But I can't figure out what I have to change to get my ".sh" script to work.

Any suggestions?

/\/\ark

P.S. - I'm running CygWin 1.3.12-2 under Windows XP.

 
 
 

CygWin - PATH finds "myscript.sh" but not "myscript"

Post by Andreas K?h? » Sat, 20 Jul 2002 08:29:27


Submitted by "Mark Prenter" to comp.unix.shell:

Quote:> Hi, I'm new to CygWin,  I've written a script called "myscript.sh" and
> placed it in a directory in the PATH.  I am able to run the script from
> anywhere using the name "myscript.sh"......but I would also like to be able
> to run it by just typing "myscript" without the ".sh."

> I'm pretty sure this is possible because when working with MKS Toolkit,
> which uses a Korn Shell, it worked that way out of the box.  CygWin seems to
> have some of this functionality because ".exe" files will work like this.
> But I can't figure out what I have to change to get my ".sh" script to work.

> Any suggestions?

> /\/\ark

> P.S. - I'm running CygWin 1.3.12-2 under Windows XP.

Ignoring .exe is a feature of Cygwin, it is not usually how Unix
works.  If you want to execute your script as "myscript" as well
as "myscript.sh", both must be available on the system.  One way
to do this is to make "myscript" a symbolic link to
"myscript.sh":

cd /directory/of/myscript.sh/somewhere/
ln -s myscript.sh myscript

--
Andreas K?h?ri
--------------------------------------------------------------
Stable, secure, clean, free:  www.netbsd.org

 
 
 

CygWin - PATH finds "myscript.sh" but not "myscript"

Post by Dan Merc » Sat, 20 Jul 2002 22:59:56




> Hi, I'm new to CygWin,  I've written a script called "myscript.sh" and
> placed it in a directory in the PATH.  I am able to run the script from
> anywhere using the name "myscript.sh"......but I would also like to be able
> to run it by just typing "myscript" without the ".sh."

> I'm pretty sure this is possible because when working with MKS Toolkit,
> which uses a Korn Shell, it worked that way out of the box.  CygWin seems to
> have some of this functionality because ".exe" files will work like this.
> But I can't figure out what I have to change to get my ".sh" script to work.

> Any suggestions?

> /\/\ark

> P.S. - I'm running CygWin 1.3.12-2 under Windows XP.

I am guessing the exe magic is done in their version of the
exec(2) command. I am also guessing you gave the script an
extension so you could edit it with M$ editors,  which can
lead to grief if they startt using CR-LF as a line ending.
Ironically,  I installed Cygwin just so I wouldn't have to
use Gates's lame editors.  I primarily use nedit
(http://www.nedit.org) but I also use vim.  Nedit requires
X server software - I have Reflections X - but you can also put
up XFree86.

Shell scripts do not require extensions.  Unix style editors
do not require extensions.  Leave off the extensions.

--
Dan Mercer

 
 
 

CygWin - PATH finds "myscript.sh" but not "myscript"

Post by Mark Prente » Wed, 31 Jul 2002 00:20:46


Thanks, I guess I was hoping that there was some sort of alias thing I could
do to get it to ignore the .sh and run it as a script.

/\/\ark




> > Hi, I'm new to CygWin,  I've written a script called "myscript.sh" and
> > placed it in a directory in the PATH.  I am able to run the script from
> > anywhere using the name "myscript.sh"......but I would also like to be
able
> > to run it by just typing "myscript" without the ".sh."

> > I'm pretty sure this is possible because when working with MKS Toolkit,
> > which uses a Korn Shell, it worked that way out of the box.  CygWin
seems to
> > have some of this functionality because ".exe" files will work like
this.
> > But I can't figure out what I have to change to get my ".sh" script to
work.

> > Any suggestions?

> > /\/\ark

> > P.S. - I'm running CygWin 1.3.12-2 under Windows XP.

> I am guessing the exe magic is done in their version of the
> exec(2) command. I am also guessing you gave the script an
> extension so you could edit it with M$ editors,  which can
> lead to grief if they startt using CR-LF as a line ending.
> Ironically,  I installed Cygwin just so I wouldn't have to
> use Gates's lame editors.  I primarily use nedit
> (http://www.nedit.org) but I also use vim.  Nedit requires
> X server software - I have Reflections X - but you can also put
> up XFree86.

> Shell scripts do not require extensions.  Unix style editors
> do not require extensions.  Leave off the extensions.

> --
> Dan Mercer