LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Scripts need full path on shebang line; affects urxvt (https://www.linuxquestions.org/questions/linux-software-2/scripts-need-full-path-on-shebang-line%3B-affects-urxvt-878037/)

catkin 04-30-2011 01:48 PM

Scripts need full path on shebang line; affects urxvt
 
Hello :)

A frequently used custom perl script used with urxvt stopped working. There is no logged change to the system shortly before it started happening.

The as-distributed urxvt perl scripts have #! perl; the long-working custom script had the same for consistency. Investigation showed test scripts now need a full path on the shebang line despite PATH including the interpreter's directory:
Code:

c@CW8:~/d/bin/try$ cat hello_world.pl
#! perl
print "Hello World\n";
c@CW8:~/d/bin/try$ ./hello_world.pl.org
bash: ./hello_world.pl.org: perl: bad interpreter: No such file or directory
c@CW8:~/d/bin/try$ cat hello_world.pl
#! /usr/bin/perl
print "Hello World\n";
c@CW8:~/d/bin/try$ ./hello_world.pl   
Hello World
c@CW8:~/d/bin/try$ type perl
perl is /usr/bin/perl
c@CW8:~/d/bin/try$ ls -l /usr/bin/perl
lrwxrwxrwx 1 root root 10 Apr 30 22:48 /usr/bin/perl -> perl5.10.1
c@CW8:~/d/bin/try$ ls -l /usr/bin/perl5.10.1
-rwxr-xr-x 1 root root 1402248 Oct  3  2009 /usr/bin/perl5.10.1
c@CW8:~/d/bin/try$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/lib64/java/bin

A bash hello_world.sh script behaved similarly. IDK if that is normal (I always use full paths in shebang lines); the execve (2) man page says "#! interpreter [arg] ... the interpreter must be a valid pathname".

As part of the investigation I had added logging to the custom urxvt perl script; no logs appeared. After changing its shebang line to a full path, logs appeared but paste from X-CLIPBOARD by Super+V still did not work or log. I changed all the perl scripts in /usr/lib64/urxvt/perl to full path shebang lines but Super+V still did not work :(

:scratch:

Best

Charles

javpra 04-30-2011 04:48 PM

Scripts need full path on shebang line; affects urxvt
 
Hello catkin,

It doesn't look like an issue with the first line of the script, but simply a typo. Your first line runs `cat` on a file called `hello_world.pl` and it returns the file. However, when you are trying to run the file you are using `./hello_world.pl.org` which doesn't look like it exists. Do an `ls` and make sure that `hello_world.pl.org` is there. So long as `perl` is in $PATH it should work. If that was not it let me know and we'll keep looking.

catkin 04-30-2011 11:09 PM

Thanks javpra :)

That was a typo in the post; I actually had hello_world.pl.org (org = original) with #! perl and hello_world.pl with #! /usr/bin/perl. For simplicity (ha! :eek:) I posted as if the file had been modified. The behaviour was as described.

A Debian 6.0 Squeeze system shows the same behaviour (and this is verbatim!):
Code:

docmgt@CW8vDS:~/bin$ cat hello_world.sh
#! bash
echo 'Hello World'
docmgt@CW8vDS:~/bin$ ./hello_world.sh
-bash: ./hello_world.sh: bash: bad interpreter: No such file or directory
docmgt@CW8vDS:~/bin$ sed -i 's|bash|/bin/bash|' hello_world.sh
docmgt@CW8vDS:~/bin$ cat hello_world.sh
#! /bin/bash
echo 'Hello World'
docmgt@CW8vDS:~/bin$ ./hello_world.sh
Hello World

So the behaviour is normal. Sorry for the red herring.

Presumably the full path to perl is not necessary in the urxvt perl scripts because urxvt does not rely on the shebang line.

I re-installed urxvt (and perl, for good measure) but urxvt Super+V (paste) functionality is still broken :(

Now this looks like a urxvt problem, I'll post in the urxvt mailing list.

catkin 05-02-2011 11:48 AM

Solution posted in this LQ thread.


All times are GMT -5. The time now is 12:35 PM.