public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* B.20.1 bash question - paths sent to #!
@ 2000-02-01 13:11 Al and Patricia
  2000-02-01 21:52 ` Doug Wyatt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Al and Patricia @ 2000-02-01 13:11 UTC (permalink / raw)
  To: cygwin

Hello -

I looked in the archives and did not see a solution to this issue:

I have 3 drives on my NT 4.0 system: C: D: E:.
I have a perl script that has "#!/usr/bin/perl" in it.
I am trying to put the perl script in my path, so that I can run it from
any drive.
I am using ActiveState Perl.

Here is the situation.  First, my perl script is called "pop3", and it
resides in /e/perl/bin.  If I put /e/perl/bin in my path, then I believe
that bash calls /usr/bin/perl with the file name as /e/perl/bin/pop3.
However, AS Perl can't interpret this file name and gives a "file not found"
error.

I tried putting /perl/bin/ in my path, and this works, as long as I am "on"
the e drive.  When I go to another drive, /perl/bin does not exist, and
calling pop3 fails again.

So what I'd like is to have bash convert the Posix path of the called script
to win32 when using the #! syntax, so that AS Perl (and other interpreters)
will have a path it can work with.  Is there a workaround?

I hope this makes sense.  Let me know if can clarify.
-----------------
Al and Patricia





--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
  2000-02-01 13:11 B.20.1 bash question - paths sent to #! Al and Patricia
@ 2000-02-01 21:52 ` Doug Wyatt
  2000-02-02 13:22 ` Michael Hirmke
  2000-02-02 14:14 ` Soren Andersen
  2 siblings, 0 replies; 7+ messages in thread
From: Doug Wyatt @ 2000-02-01 21:52 UTC (permalink / raw)
  To: Al and Patricia, cygwin

Hi,

I believe I've seen some recent postings about converting pathname
formats - check the archives at < http://sourceware.cygnus.com/ml/cygwin/ >.

Quite some time back, I tried using the AS Perl with Cygwin but the final
straw was when I found that AS Perl didn't implement fork and exec.
I'd recommend trying the Cygwin port of Perl; it's fully compatible with
Cygwin and seems very stable.  Look to < http://cygutils.netpedia.net/ > if
you want to try it.

Regards,
Doug Wyatt

> Hello -
> 
> I looked in the archives and did not see a solution to this issue:
> 
> I have 3 drives on my NT 4.0 system: C: D: E:.
> I have a perl script that has "#!/usr/bin/perl" in it.
> I am trying to put the perl script in my path, so that I can run it from
> any drive.
> I am using ActiveState Perl.
> 
> Here is the situation.  First, my perl script is called "pop3", and it
> resides in /e/perl/bin.  If I put /e/perl/bin in my path, then I believe
> that bash calls /usr/bin/perl with the file name as /e/perl/bin/pop3.
> However, AS Perl can't interpret this file name and gives a "file not found"
> error.
> 
> I tried putting /perl/bin/ in my path, and this works, as long as I am "on"
> the e drive.  When I go to another drive, /perl/bin does not exist, and
> calling pop3 fails again.
> 
> So what I'd like is to have bash convert the Posix path of the called script
> to win32 when using the #! syntax, so that AS Perl (and other interpreters)
> will have a path it can work with.  Is there a workaround?
> 
> I hope this makes sense.  Let me know if can clarify.
> -----------------
> Al and Patricia
> 
> 
> 
> 
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
  2000-02-01 13:11 B.20.1 bash question - paths sent to #! Al and Patricia
  2000-02-01 21:52 ` Doug Wyatt
@ 2000-02-02 13:22 ` Michael Hirmke
  2000-02-02 14:14 ` Soren Andersen
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Hirmke @ 2000-02-02 13:22 UTC (permalink / raw)
  To: cygwin

Hi Al,

[...]
>I have 3 drives on my NT 4.0 system: C: D: E:.
>I have a perl script that has "#!/usr/bin/perl" in it.
[...]
>I am using ActiveState Perl.

I don't use AS Perl, but compiled the sources with VC++ myself.
So my configuration here is comparable to your's.

>
>Here is the situation.  First, my perl script is called "pop3", and it
>resides in /e/perl/bin.  If I put /e/perl/bin in my path, then I believe

I always have a shebang like "#!/usr/bin/perl -w" in all my perl
scripts.
I always add the directories containing my perl scripts to the path.

>that bash calls /usr/bin/perl with the file name as /e/perl/bin/pop3.
>However, AS Perl can't interpret this file name and gives a "file not found"
>error.
>
>I tried putting /perl/bin/ in my path, and this works, as long as I am "on"
>the e drive.  When I go to another drive, /perl/bin does not exist, and
>calling pop3 fails again.

You *have to* call your scripts with "perl -S
<scriptname_without_path>", even if you have added the directory to the
path.
If you don't want to do this, you would have to use the Cygwin version
of perl, which lacks a few very important modules, though.

>
>So what I'd like is to have bash convert the Posix path of the called script
>to win32 when using the #! syntax, so that AS Perl (and other interpreters)
>will have a path it can work with.  Is there a workaround?

You could write some wrapper script perhaps.

>
>I hope this makes sense.  Let me know if can clarify.
>-----------------
>Al and Patricia

Bye.
Michael.
-- 
Michael Hirmke           | Telefon +49 (911) 557999
Georg-Strobel-Strasse 81 | FAX     +49 (911) 557664
90489 Nuernberg          | E-Mail  mailto:mh@mike.franken.de
                         | WWW     http://aquarius.franken.de/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
  2000-02-01 13:11 B.20.1 bash question - paths sent to #! Al and Patricia
  2000-02-01 21:52 ` Doug Wyatt
  2000-02-02 13:22 ` Michael Hirmke
@ 2000-02-02 14:14 ` Soren Andersen
  2 siblings, 0 replies; 7+ messages in thread
From: Soren Andersen @ 2000-02-02 14:14 UTC (permalink / raw)
  To: cygwin

On 1 Feb 00, an entity purporting to be Al and Patricia [Al and Patricia 
<carat@earthlink.net>] wrote [regarding B.20.1 bash question - paths sent 
to #!]  

> I looked in the archives and did not see a solution to this issue:
> 
> I have 3 drives on my NT 4.0 system: C: D: E:.
> I have a perl script that has "#!/usr/bin/perl" in it.
> I am trying to put the perl script in my path, so that I can run it from
> any drive. I am using ActiveState Perl.

First of all, its been suggested that you had best install another Perl 
(Cygwin-built Perl) and only use it from Cygwin. That's not a bad 
suggestion, but I can easily imagine circumstances and preferences in which 
someone wouldn't want to do this. I myself have installed that Cygwin Perl 
and its fine but it is core Perl without many, many "goodies" that 
ActiveState installs for you (I am installing mods for it a bit at a time).  

> Here is the situation.  First, my perl script is called "pop3", and it
> resides in /e/perl/bin.  If I put /e/perl/bin in my path, then I believe
> that bash calls /usr/bin/perl with the file name as /e/perl/bin/pop3.
> However, AS Perl can't interpret this file name and gives a "file not
> found" error.
> 
> I tried putting /perl/bin/ in my path, and this works, as long as I am
> "on" the e drive.  When I go to another drive, /perl/bin does not exist,
> and calling pop3 fails again.
> 
> So what I'd like is to have bash convert the Posix path of the called
> script to win32 when using the #! syntax, so that AS Perl (and other
> interpreters) will have a path it can work with.  Is there a workaround?

There's no standard workaround for path problems that i know of. This 
general issue thus becomes the occasion for my first posting to this List.

Basically you can see the same thing happen if it isn't invoking Perl that you 
are trying to do, but let's say "just" invoking humble Windoze Explorer. Try 
this:
  explore.exe /E, /usr/bin
and you'll get either an unpredictable result or an error message from 
Windows telling you that there is no valid directory to explore at "/usr/bin" 
or something. The bash shell and the Cygwin innards and the Windows 
command interpretor don't all play together nicely; they speak different 
lingos. You (all) know this already.

I have a workaround. Its not pretty, maybe, but it address some long-
standing problems i have been having with shells (especially Cygwin bash) 
and Windows. This fix might be adaptable to other shells but right now i 
only guarantee that it works in bash (Cygwin b-20) and only if you either 
have an env var HOMEDRIVE set correctly (I think it was defined by 
default -- in WinNT ONLY -- upon OS installation: look in START | 
SETTINGS | CONTROL PANEL| SYSTEM | ENVIRONMENT) *or* you 
hand-edit the root drive variable $RootDrv (which on my setup is D:  
whereas on some other people's would be C:  or anything else).


ex()    {
	local RootDrv="$HOMEDRIVE"'/'
local DSpec=`echo "$1" | sed s=^/== | sed s=^'\([a-zA-Z]\)''\/'='\1:'/= `
	if [ ! $( echo "$DSpec" | grep --regexp=^[A-Za-z]':/' ) ]; then
		DSpec="$RootDrv""$DSpec"
	fi
	DSpec=$(echo $DSpec | sed s+/+'\\'+g)
	command Explorer /e,/root,$DSpec
}

Put this function in your .bashrc file (watch out for emailer line-wrapping 
messup of course)  and login to bash. It should Do The Right Thing (it opens 
an Explorer window with the specified Win-style path as the "ceiling", to get 
a normal navigatible two-pane Explorer just omit the ",/root," part).

Now, to fix things for ActivePerl:


px()    {
	local RootDrv="$HOMEDRIVE"'/'
local DSpec=`echo "$1" | sed s=^/== | sed s=^'\([a-zA-Z]\)''\/'='\1:'/= `
	if [ ! $( echo "$DSpec" | grep --regexp=^[A-Za-z]':/' ) ]; then
		DSpec="$RootDrv""$DSpec"
	fi
	DSpec=$(echo $DSpec | sed s+/+'\\'+g)
	command perl $DSpec
}

If I enter this, for instance:
  px /e/scr/test_path.p
I get the right result (the script, which actually exists on my system, is run 
by Perl).

The key is that sed is nearly completely *broken* in its Cygwin incarnation. 
The quoting gymnastics are required and represent hours of trial and error 
to arrive at the empirical results demonstrated above (so I would 
recommend that the traditional 'flame the List newbie' flames be withheld 
or directed to /dev/null) ...

  HTH,
      soren andersen


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
@ 2000-02-02  7:07 Earnie Boyd
  0 siblings, 0 replies; 7+ messages in thread
From: Earnie Boyd @ 2000-02-02  7:07 UTC (permalink / raw)
  To: Ian Miller, Cygwin Mailing List

--- Ian Miller <ian@gingerspice.demon.co.uk> wrote:
-8<-
> I use Cygwin and Active State Perl but I never noticed this before, because
> I always run my scripts from the directory that they are in! However, one
> possible work around that I've just tried is to simply set up a shell script
> in your bin directory, which then calls Active State Perl with the correct
> DOS-style paths, e.g.
> 
> --- file: /c/bin/myscript ---
> 
> #!/usr/local/bin/tcsh -f
> #
> # I know this is a bad shell to use, but it's just an example! :)
> #
> 
> perl c:\\src\\perl\\myscript.pl "$argv"
> 
> --- end of file ---

--- file: c:\bin\stupid.script

#! c:/winnt/system32/cmd /c
#
# This is probably a worse example.
#

perl c:\src\perl\myscript.pl $@

#                            ^^  to be replaced with what DOS would expect
#                                which I haven't the slightest clue.

--- end of file ---


Note, I have a noop program named #.exe that is on the PATH that CMD uses.

--- File: noop.c

int main ( void ) { return 0; }

--- end of file ---

gcc -o #.exe noop.c


Regards,

=====
Earnie Boyd < mailto:earnie_boyd@yahoo.com >
Cygwin Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
  2000-02-02  5:44 Earnie Boyd
@ 2000-02-02  6:17 ` Ian Miller
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Miller @ 2000-02-02  6:17 UTC (permalink / raw)
  To: Cygwin Mailing List

Earnie Boyd wrote:
> 
> --- Al and Patricia <carat@earthlink.net> wrote:
> > I looked in the archives and did not see a solution to this issue:
> >
> > I have 3 drives on my NT 4.0 system: C: D: E:.
> > I have a perl script that has "#!/usr/bin/perl" in it.
> > I am trying to put the perl script in my path, so that I can run it from
> > any drive.
> > I am using ActiveState Perl.
> 
> Note: You ain't gonna get it working.  Non-Cygwin programs do _not_ understand
> the Cygwin paths.  You'll need to get the Cygwin port of perl to have any luck
> with what you're trying to do.  See the http://sourceware.cygnus.com/cygwin/
> page for URL pointers.

I use Cygwin and Active State Perl but I never noticed this before, because
I always run my scripts from the directory that they are in! However, one
possible work around that I've just tried is to simply set up a shell script
in your bin directory, which then calls Active State Perl with the correct
DOS-style paths, e.g.

--- file: /c/bin/myscript ---

#!/usr/local/bin/tcsh -f
#
# I know this is a bad shell to use, but it's just an example! :)
#

perl c:\\src\\perl\\myscript.pl "$argv"

--- end of file ---

cheers,
ian

-- 
+------------------------------+----------------------------------------------+
| ian miller                   | My other MUA is a GNU.                       |
| ian@gingerspice.demon.co.uk  | http://www.gingerspice.demon.co.uk           |
+------------------------------+----------------------------------------------+

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: B.20.1 bash question - paths sent to #!
@ 2000-02-02  5:44 Earnie Boyd
  2000-02-02  6:17 ` Ian Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Earnie Boyd @ 2000-02-02  5:44 UTC (permalink / raw)
  To: Al and Patricia, cygwin

--- Al and Patricia <carat@earthlink.net> wrote:
> Hello -
> 
> I looked in the archives and did not see a solution to this issue:
> 
> I have 3 drives on my NT 4.0 system: C: D: E:.
> I have a perl script that has "#!/usr/bin/perl" in it.
> I am trying to put the perl script in my path, so that I can run it from
> any drive.
> I am using ActiveState Perl.
> 

Note: You ain't gonna get it working.  Non-Cygwin programs do _not_ understand
the Cygwin paths.  You'll need to get the Cygwin port of perl to have any luck
with what you're trying to do.  See the http://sourceware.cygnus.com/cygwin/
page for URL pointers.

Regards, 

=====
Earnie Boyd < mailto:earnie_boyd@yahoo.com >
Cygwin Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-02-02 14:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-01 13:11 B.20.1 bash question - paths sent to #! Al and Patricia
2000-02-01 21:52 ` Doug Wyatt
2000-02-02 13:22 ` Michael Hirmke
2000-02-02 14:14 ` Soren Andersen
2000-02-02  5:44 Earnie Boyd
2000-02-02  6:17 ` Ian Miller
2000-02-02  7:07 Earnie Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).