Hello, John.
Since /home/user is probably not on your path (for good security reasons), I would not expect this to run anyway.
Try moving it to /home/user/bin or a directory that is in your path.
On my CentOS4.1 system, putting it in /root does not make it work - I still have to do ./test.sh. /root is not in the path. QED.
Yes, but I tested those scripts with the complete path, or with './test.sh' when being in the directory, so it doesn't seem to be related to a path problem.
What are the directory permissions as well? ls -ld /home/user and compare with ls -ld /root or wherever it runs OK. You only need execute access on a directory to be able to use it but you need read access if you want to find a file in it.
These are the permissions for those files:
[root@box /]# ls -ld /home drwxr-xr-x 6 root root 4096 Aug 2 14:58 /home [root@box /]# ls -ld /root drwxrwx--- 10 root root 4096 Aug 2 14:58 /root
/home is where the script is buggy, and /root is where the script works. Now for any reason the script works also in the / directory if I create a new one. If I copy the buggy file from /home to / it works there. If I move the buggy file from /home to / it doesn't work there... go figure..
Have you tried strace?
strace ./test.sh 2>&1 > test.trace (or whatever)
No, I haven't. I have done this right now with both the buggy and correct files. Here is the output of the difference between both strace files. It seems that there is something interesting about failing to open the /dev/tty, but I don't know how to solve that:
[root@box /]# diff /test.trace /home/test.trace 3c3 < brk(0) = 0x977b000 ---
brk(0) = 0x9cd1000
35,38c35,38 < open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3 < close(3) = 0 < brk(0) = 0x977b000 < brk(0x979c000) = 0x979c000 ---
open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = -1 ENXIO (No such device or address) ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe4aa40) = -1 ENOTTY (Inappropriate ioctl for device) brk(0) = 0x9cd1000 brk(0x9cf2000) = 0x9cf2000
48c48 < time(NULL) = 1123010862 ---
time(NULL) = 1123011577
70c70 < stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 ---
stat64("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
72c72 < getpid() = 3144 ---
getpid() = 3168
77,78c77,78 < getppid() = 3143 < getpgrp() = 3143 ---
getppid() = 3167 getpgrp() = 3167
82c82 < ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbff0f1c8) = -1 ENOTTY (Inappropriate ioctl for device) ---
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe4ab58) = -1 ENOTTY (Inappropriate ioctl for device)
96c96,97 < fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0 ---
fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe4a28c) = -1 ENOTTY (Inappropriate ioctl for device)
It seems that we are getting nearer this time ..
Thanks, Daniel