in reply to From chat to here :) chdir() and test -f issues.

Don't waste your time guessing. Perl provides the answer:

$ perl -e 'if (-f "foobarama") { print "file exists" } elsif ($!) { pr +int "$!\n" }' No such file or directory $ perl -e 'if (-f "/root/foobarama") { print "file exists" } elsif ($! +) { print "$!\n" }' Permission denied

Replies are listed 'Best First'.
Re: Re: From chat to here :) chdir() and test -f issues.
by snafu (Chaplain) on Jul 05, 2001 at 00:19 UTC
    Yup. Already did this. And from the command line it works fine. BTW, I am running the script as the user that is running the script or in other words, I have pretty much eliminated a permissions issue. Anyway, I am getting closer and I believe those of you who stated that there maybe a hidden character somewhere must be on the right track...

    [qadmin@concon qw]$ perl -e ' $gamedir = "fortress"; $HOME = $ENV{'HOME'}; $mapname = "2fort5"; if ( -f "$HOME/$gamedir/maps/$mapname.bsp" ) { print "It exists!\n" } +else { print "$!\n" }; ' It exists! [qadmin@concon qw]$ perl -e ' $gamedir = "fortress"; $HOME = $ENV{'HOME'}; $mapname = "2fort5qra"; if ( -f "$HOME/$gamedir/maps/$mapname.bsp" ) { print "It exists!\n" } +else { print "$!\n" }; ' No such file or directory [qadmin@concon qw]$

    Since the script uses other means whereby to get these values and it doesn't work vs my putting these values in by hand where I know there are no hidden characters I can deduce that there must be some hidden character slipping in somewhere in the runtime of the script. I don't see why there would be a '\r' in this thing but it is possible so I will try that out and see how I fare. A '\r' seems like the most logical thing that could be flubbing this up.

    Thanks fellow monks. I will let everyone know the outcome once I am done.

    ----------
    - Jim