Operating System - HP-UX
1834814 Members
2823 Online
110070 Solutions
New Discussion

find: cannot get 'pwd' script error

 
Ratzie
Super Advisor

find: cannot get 'pwd' script error

I know I posted earlier about this error, and the fix was to just cd to the directory first, then do a find, but if I have it working correctly on one machine and not another, I need to know why? Same permission, owners, groups...

Here is the problem...
I have an HP 11.00 system.
I am running into this problem that when I run a script it returns an error...
find: cannot get 'pwd'

This is from the command...
find /home/ac/log -name "archbu.log.*" -type f -mtime +7 -exec /bin/rm -r {} ";"

I have tried it with \; at the end as well, and still no go.
The funny thing is, is that I have this identicle script on another identicle server, and it works perfect. All permission's are the same.

This script is being run from roots crontab...
su acadmin -c /home/ac/scripts/backup/d2t_archbu.sh

I know if I cd to the directory first, I know it will work, but why can't it work with cd'ing to the directory, like the other server.
6 REPLIES 6
Jeff Schussele
Honored Contributor

Re: find: cannot get 'pwd' script error

Hi,

Is /home/ac/log linked to another directory?
If so try using -follow in that command.

HTH,
Jeff

PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jeff Schussele
Honored Contributor

Re: find: cannot get 'pwd' script error

Oh & you might also want to use -path or -print to force the entire fully pathed filename to output into the rm command if it's not a linked dir.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Robert-Jan Goossens
Honored Contributor

Re: find: cannot get 'pwd' script error

Hi,

Do you use the automounter ? If so the homedir is not mounted before you use the cd command.

Robert-Jan
Ratzie
Super Advisor

Re: find: cannot get 'pwd' script error

I HAVE FOUND MY PROBLEM!!!

I changed the permissions on /rootuser, since root was running the crontab, and everything works fine.

WOW, what alitte gotcha!

Thank you all.
john korterman
Honored Contributor

Re: find: cannot get 'pwd' script error

Hi,
the problem is really that find tries to read in the CURRENT directory, no matter whether this is relevant for the action to be taken or not. The outcome of your command will depend on the directory from which you execute the command. If you cd to any directory in which your user has read access the error will not appear.
I have just tried thie:

#

# ls -ld .
d-wx--x--x 2 jxk users 96 Jan 26 20:09 .
# find /tmp -type f -name "btmp.stat"
find: cannot get 'pwd'
# cd ..
# ls -ld .
drwxr-xrwx 23 jxk users 2048 Jan 26 20:09 .
# find /tmp -type f -name "btmp.stat"
find: cannot open /tmp/.AgentSockets
find: cannot open /tmp/syslogtp
find: cannot open /tmp/tp-sc
find: cannot open /tmp/hp11templ
find: cannot open /tmp/fbatp
find: cannot open /tmp/shitp
find: cannot open /tmp/oper
find: cannot open /tmp/msg
find: cannot open /tmp/app
find: cannot open /tmp/opcmsg13
find: cannot open /tmp/shi
find: cannot open /tmp/wnt
/tmp/btmp.stat

as can be seen it is not relevant for the find command whether it can read the current dir or not. But to explain why this is so... well, that is a challenge.

regards,
John K.

p.s. I still think you should finish your find command by the escaped semicolon.
it would be nice if you always got a second chance
john korterman
Honored Contributor

Re: find: cannot get 'pwd' script error

sorry the first command in my example was lost. It was:
# pwd
/home/jxk/newdir
it would be nice if you always got a second chance