scripts can't find the pwd

This is a discussion on scripts can't find the pwd within the Linux Administration forums, part of the Linux Forums category; Hi, Is this (hopefully) an old, familiar problem? Sometimes bash scripts can't seem to find files or subdirectories of ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-05-2005
Neil Ferguson
 
Posts: n/a
Default scripts can't find the pwd

Hi,

Is this (hopefully) an old, familiar problem? Sometimes bash scripts can't
seem to find files or subdirectories of the present working directory. So
that, for example, executing a shell script from a particular directory,
instead of:

for adir in $someSubDirs # a list of subdirectories of the pwd
do
cd $adir
...this and that...
cd ..
done

I must use:
for adir in $someSubDirs
do
cd ./$adir ### prepended relative pwd
...this and that...
cd ..
done

This behavior most recently caused me problems with NIS installation,
affecting the execution of /var/yp/Makefile.

This happening in bash, Suse 8.2. Any suggestions?

Neil Ferguson



Reply With Quote
  #2 (permalink)  
Old 11-14-2005
Lars Kellogg-Stedman
 
Posts: n/a
Default Re: scripts can't find the pwd

On 2005-06-05, Neil Ferguson <nferguson@hotmail.com> wrote:
> cd ./$adir ### prepended relative pwd


There should be no different between "cd $dir" and "cd ./$dir".

Is the problem reliably reproduceable? Can you create a set of
conditions that will trigger it? Can you show us a complete script that
demonstrates the problem and the output it produces?

-- Lars
--
Lars Kellogg-Stedman <jn8g543ro0hu8fr@jetable.net>
This email address will expire on 2005-11-21.

Reply With Quote
  #3 (permalink)  
Old 11-15-2005
Chris F.A. Johnson
 
Posts: n/a
Default Re: scripts can't find the pwd

On 2005-11-14, Lars Kellogg-Stedman wrote:
> On 2005-06-05, Neil Ferguson <nferguson@hotmail.com> wrote:
>> cd ./$adir ### prepended relative pwd

>
> There should be no different between "cd $dir" and "cd ./$dir".


There can be if $CDPATH is set.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Reply With Quote
  #4 (permalink)  
Old 11-15-2005
Lars Kellogg-Stedman
 
Posts: n/a
Default Re: scripts can't find the pwd

> There can be if $CDPATH is set.

Good catch.

-- Lars

--
Lars Kellogg-Stedman <1o4ibj70m3vooae@jetable.org>
This email address will expire on 2005-11-22.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:24 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0