deprecated has asked for the wisdom of the Perl Monks concerning the following question:

I have a curious permissions problem with perl. This is a snippet from my ~/.bashrc:
# determine terminal D_TERM=`tty | perl -e 'print /tty/ ? "vt220" : "xterm-color"'` TERM=${D_TERM}
This is interesting since I can actually execute the perl binary, and I am a member of the perlusers group (whom own the perl directory). Here's more interesting stuff:
18:25:28 [alex : macachu : ~] [3] $ tty | perl -e 'print /tty/ ? "vt220" : "xterm-color"' Can't open perl script "-e": Permission denied 18:25:55 [alex : macachu : ~] [5] $ tty | perl <<EOP [ Continued ] > print /tty/ ? "vt220" : "xterm-color" [ Continued ] > EOP xterm-color18:26:30 [alex : macachu : ~] [6] $
So there is something in the way that perl is interpreting the -e. This worries me. What would allow me to use heredoc perl as well as scripts but not -e?

freaked out,
brother dep.

ps. in contrast to some of my recent posts, this is my home box, and i am rootly here. :)
pps. i just also noticed that this will always print the latter since its evaluating $_ when I really want $_[0].
update: no, there are no perl aliases.
update2:well, merlyn rightly suggested i strace(1) or truss(1) it, and lo, /dev/null was not world readable. problem fixed.

--
Laziness, Impatience, Hubris, and Generosity.

Replies are listed 'Best First'.
Re: Perl '-e' permissions problem. (code)
by merlyn (Sage) on May 04, 2001 at 02:54 UTC
    A guess, but -e has to create a script under /tmp/perl$$ or something like that. Are you sure your /tmp is writable, and that there are no scripts left over in there that shouldn't be?

    -- Randal L. Schwartz, Perl hacker

      Actually, starting with perl5.005, Perl no longer creates a temporary file in /tmp when -e is used. That behavior was a potential security hole, because another process could mess with the file.

      Update: I used this in a trivia question at a Mongers party a couple years ago:

      Q. Three diagnostic messages are obsolete in perl5.005. All three were related to what Perl feature?

      A. The -e command line switch. (All three reported errors with the temp file for -e; in perl5.005 -e no longer creates a temp file.)

Re: Perl '-e' permissions problem. (code)
by chipmunk (Parson) on May 04, 2001 at 02:39 UTC
    I don't suppose that 'perl' is aliased to something like 'perl --'? That's the only thing I can think of off the top of my head.

    Ahh, that would give an error like Can't open perl script "-e": No such file or directory What version of perl are you running?

Re: Perl '-e' permissions problem. (code)
by MeowChow (Vicar) on May 04, 2001 at 09:08 UTC
    /dev/null wasn't world readable? now that's what I call a paranoid sysadmin... <g>
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print