Subject: Re: bash/sh program interpreter problems...
From: Robert Schmidt <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 25 Oct 2004 20:42:17 +0200

Reini Urban wrote:
> Robert Schmidt schrieb:
> 
>> I have the following two programs in /usr/local/bin:
>>
>> --- test.btm
>> #!/usr/local/bin/testint.sh
>> echo hello from test.btm
> 
> 
> naming a shell script .btm is not a good idea, since .btm files are 
> usually 4NT batch files.

This is exactly what I'm doing.  I want to be able to run 4NT batch 
files from e.g. bash.

Just to make it clear, the above *is* a 4NT batch file - not a shell 
script.  I assumed talking about 4NT would just confuse matters, but 
here it is:

I've defined a 4NT alias "#!" for "rem", which makes 4NT ignore the 
interpreter spec.  Further, testint.sh is actually my "4NT interpreter", 
4ntsh.sh:

#!/bin/sh
FILE=`cygpath -w $1`
shift
/usr/local/bin/4nt/4nt.exe /c "$FILE" $@

Next, any 4NT batch file I want to run from bash should do so if I put 
this line in it:

#!/usr/local/bin/4ntsh.sh
...

And as I said, this works often, and often not at all.

> same for .h files.
> windows has some internal registry key which extensions are executable.

I'm aware of this, but that has no impact on how cygwin runs executable 
files (AFAIK).

> chmod +x /usr/local/bin/test.btm
> chmod +x /usr/local/bin/test.h
> 
> does the explicit path help?

No...  all files that should be +x, are.

> --- test.h
> #!/bin/bash
> /usr/local/bin/test.btm
> 
> One should not assume that test.btm is executable.

On my setup, I do.  I regularly run a "fix permissions" script which 
gives +x to all *.sh, *.btm, *.pl, etc. under /usr/local/bin (typically 
after synchronizing with unison, which does not yet propagate permissions).

> BTW: I have the same problems, with some php or java wrappers. The first 
> call gives this error message "bad interpreter", the seconds works fine 
> then.

All right - that sounds like the problem I'm trying to describe!  It's 
good to hear that I'm not alone.  Any useful info?  google gave me 
3-year old threads which left me in the dark.

The fact that the error message occurs at rather random times make me 
suspect a bug in cygwin.  I wonder if it can be the same problem as the 
"PID reuse" problem mentioned in several parallel threads?  I don't yet 
have the guts to start building and patching bash myself - maybe later 
this week.

Thanks,
Rob

--
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/