Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Fri, 26 Sep 2003 10:52:41 -0400
From: Al Goodniss <amg@townisp.com>
To: cygwin@cygwin.com
Subject: Re: /etc/profile not being executed by cron job
Message-ID: <20030926145241.GB3228@townisp.com>
Reply-To: amg@townisp.com
References: <20030925161417.GA3476@townisp.com> <Pine.GSO.4.56.0309251216360.3193@slinky.cs.nyu.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.GSO.4.56.0309251216360.3193@slinky.cs.nyu.edu>
User-Agent: Mutt/1.4i
X-Spam-Status: No, hits=-105.0 required=8.0
	tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,
	      REPLY_WITH_QUOTES,USER_AGENT_MUTT,USER_IN_WHITELIST
	version=2.55
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)

Thanks Igor.

I followed your adivce and changed the #! line to #!/usr/bin/bash -l and that worked for me. The script I'm using to do backups automatically moves itself around using absolute paths so having profile do that last 'cd "$HOME"' wasn't an issue.

-Al


On Thu, Sep 25, 2003 at 12:38:09PM -0400, Igor Pechtchanski wrote:
> On Thu, 25 Sep 2003, Al Goodniss wrote:
> 
> > Hi,
> >
> > Please point me to what I missed. I have a simple cron job doing backups
> > using tar and find. Works flawlessly in an interactive shell. Cron also
> > works fine for fetching mail, etc. The combination doesn't work.
> >
> > When I run my bash (tcsh also fails) script via Cron the wrong find is
> > found. Instead of /usr/bin/find I get the windows version. My
> > /etc/profile does prepend the directories, the permissions seen accurate
> > - as per the other fixes that were in the archives.
> >
> > What did I miss?
> >
> > -Al
> >
> > --- Test script ---
> > #!/usr/bin/bash
> > [snip]
> 
> The regular invocation of bash is a non-login shell, and thus won't
> execute /etc/profile.
> 
> Try changing the #! line to "#!/usr/bin/bash -l".  Be aware that you will
> not be able to use a relative path either to invoke the script or inside
> the script after that, as /etc/profile does a 'cd "$HOME"'.
> 
> Alternatively, you can add the following to the top of the script:
> 
> if ! shopt -q login_shell; then
>   exec -l /bin/bash --login "$PWD/$0" "$PWD" "$@"
> fi
> cd "$1"
> shift
> 
> The above should work even with relative paths, but I haven't tested it
> extensively.
> 	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!
> 
> "I have since come to realize that being between your mentor and his route
> to the bathroom is a major career booster."  -- Patrick Naughton


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

