www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/26/16:04:32

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <4A959537.7020900@bopp.net>
Date: Wed, 26 Aug 2009 15:04:07 -0500
From: Jeremy Bopp <jeremy AT bopp DOT net>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: Dexter_Michael AT emc DOT com, cygwin AT cygwin DOT com
Subject: Re: Changing HOME for PERL
References: <CC93624851A47D42AFD22FB06BCD2D9A0234B8A7 AT CORPUSMX80B DOT corp DOT emc DOT com>
In-Reply-To: <CC93624851A47D42AFD22FB06BCD2D9A0234B8A7@CORPUSMX80B.corp.emc.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------enigFE225F984E7ABD92646B915B
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Dexter_Michael AT emc DOT com wrote:
> Hello,
>=20
> I installed Cygwin yesterday and when I run it and look at "pwd" my path
> is set to:   /cygdrive/h
>=20
> I read the FAQ and when I type "set HOME" from a Windows CLI, it is set
> to:
> HOME=3DH:\
>=20
> I am using Cygwin for PERL.=20=20
>=20
> I just took a PERL course and in class Cygwin was configured for:
> /usr/bin/perl
>=20
> This was perfect because I could make my SheBang look like:=09
> #!/usr/bin/perl

Looking through the rest of your message, it appears that you don't have
a clear understanding of the SheBang line and its use.  Either that, or
I'm just missing something.  Sorry if you already understand what follows.

The SheBang line tells Cygwin where the interpreter for the script
you're running is located.  In your case, you want the program at
/usr/bin/perl to run the script when under Cygwin.  This is because the
Perl program is installed to /usr/bin/perl.

Under a Unix system, the SheBang line has the same function, but as you
have apparently discovered, the Perl program is often installed
elsewhere on those systems.  This would require a different SheBang line
of course unless you're a little clever.  See below...

> I would like to do that again with the Cygwin I installed myself
> yesterday.

Unless you did something very strange in your Cygwin installation, it
should already be set up so that using a SheBang line as you did in your
class will work without modification.  If the scripts you made in class
under Cygwin are not working for you in your personal Cygwin
installation, please send along the specific errors you see when you try
to run those scripts.

> I did modify /etc/passwd.=20=20
> The last line had: 	...:/cygdrive/h:/bin/bash
> and I changed it to:	...:/usr/bin/perl:/bin/bash

I don't think this change will solve the problem you're having.
Assuming you modified the line corresponding to your account, you are
telling Cygwin that you want your home directory to be /usr/bin/perl.
However, /usr/bin/perl is not a directory but rather a program file.

> But when I open a new Cygwin session it remembers the old /cygdrive/h

Since you have a Windows environment variable set to H:\, it takes
precedence over any setting you place into /etc/passwd.  If you do
indeed want whatever you place into /etc/passwd to take effect, you need
to remove that environment variable definition before starting your
shell session.  Andy Koppe already covered those details.

> Could someone help me?  I don't want to have to change my SheBang
> everytime I deploy a PERL script to Unix after having created it in
> Cygwin on Windows.

There are a number of solutions for writing Perl scripts which can
automatically handle differing locations for the Perl installations on
various systems.  What I do for the scripts I maintain is set the
SheBang line as follows:

#!/usr/bin/env perl

Then the only requirement for users is that the Perl program (perl) be
available in the PATH environment variable when they run the script.
When they run the script, the env program finds perl in PATH and runs it
to execute the script.  Since the env program is generally available as
/usr/bin/env and most users have PATH set to include perl, this method
has been highly successful.

-Jeremy


--------------enigFE225F984E7ABD92646B915B
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqVlTwACgkQHt4KKRq6ZjddBwCeKl/Eyt5aDK+JtDantHA3/8fv
7rsAn1dR9VszVcQCh+63bT3Myixl0qQP
=Vd1b
-----END PGP SIGNATURE-----

--------------enigFE225F984E7ABD92646B915B--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019