I am trying to run following perl script on Red Hat 6.2 (as shipped) and with perl perl-5.00503-10. The script name is showdisk.pl which is being executed as ./showdisk.pl. The perl binary is in the standard place /usr/bin/perl. #! /usr/bin/perl foreach $_ ( `df -k | grep -v "Filesystem"` ) { local($device, $size, $used, $free, $percent, $mount); ($device, $size, $used, $free, $percent, $mount) = split(/\s+/); chop($percent); print "$percent\n"; } This script won't run and exits with an error "bash: ./showdisk.pl: No such file or directory" When run with "strace ./showdisk.pl" I am getting error message: execve("./showdisk.pl", ["./showdisk.pl"], [/* 19 vars */]) = 0 strace: exec: No such file or directory However the script runs well after I add an option to perl, that is "#! /usr/bin/perl -w" The script after the modification: #! /usr/bin/perl -w foreach $_ ( `df -k | grep -v "Filesystem"` ) { local($device, $size, $used, $free, $percent, $mount); ($device, $size, $used, $free, $percent, $mount) = split(/\s+/); chop($percent); print "$percent\n"; } I think that it is a bug since this script use to work previously in addition I had some people to look at the script too. Also if you look at the strace output it seems that "exec" can not find a script or the perl command. Yes, the script does have rwx permission.
Cutting and pasting this to a file doesn't let me reproduce this. You might try removing the space between the "#!" and the "/usr/bin/perl", as that is not recommended practice.
Removing the space between #! and /usr/bin/perl -w does not work -- I got the same result. However, after your comment about cutting and pasting I found out that the return characters are causing the problem with the script. After cleaning the scripts from return characters the script is working without the help of '-w' option to perl. I have cleaned up the script with following command "tr '\r' ' ' < showdisk.pl > after.pl". showdisk.pl is the original script (the problem script). It's a programmer error not a bug. Thank you.