http://qs321.pair.com?node_id=663985


in reply to Re: Where should I post such things?
in thread Where should I post such things?

Hi,
small correction:
exec does not find the file although it should:
~/tmp$ ./x bash: ./x: /blabla: bad interpreter: No such file or directory ~/tmp$ perl -e 'exec("x") || die($!)' No such file or directory at -e line 1. ~/tmp$ perl -e 'exec("~/tmp/x") || die($!)' sh: /home/svenXY/tmp/x: /blabla: bad interpreter: No such file or dire +ctory
but
$ perl -e 'exec("pwd") || die($!)' /home/svenXY/tmp
So now you know why the messages are different, but I'm confused as to why exec does not find file x...
Regards,
svenXY

Replies are listed 'Best First'.
Re^3: Where should I post such things?
by Corion (Patriarch) on Jan 24, 2008 at 11:21 UTC

    exec respects $ENV{PATH} (or rather, exec uses the OS, and the OS respects $ENV{PATH}), and "." seems to be not in the path (and the OS seems to be one which does not have "." as a mandatory default in the list of directories searched for the executable).

Re^3: Where should I post such things?
by parv (Parson) on Jan 24, 2008 at 11:23 UTC

    In both cases -- according to ktrace(1) on FreeBSD 6-STABLE with Perl 5.8.8 in zsh 4 -- perl is complaining, through execve(2), about the missing interpreter not the file itself being executed.

    Corion's reply reminded me that I just had added '.' to the path; thanks. It turns out the message, or rather error from execve(2), is the same whether the problem is not finding the file being executed, or if found, with missing interpreter listed in the file. Anyawy, what OP said.