Question : Getting (2)No such file or directory while trying to run a CGI File

I have a working CGI Script that when served in a browser generates a cookie.  As I needed to have a very similar script, I've made a copy with slight changes, and renamed the file.  

However, although I can run the original fine, when I try to run the new one, I get a blank browser screen.  System Error logs show (2)No such file or directory: exec of ... failed.

File permissions/ownerships are the same on the two files, and the filename is correct.

Answer : Getting (2)No such file or directory while trying to run a CGI File

Ok, so I've figured it out!  
As the files were updated on a Windows machine, it appears that there were dos characters somewhere in the file.

Running the cgi file from the command line:
> ./nph-247realmedia-opt-out.cgi
showed an error of bad interpreter: No such file or directorybin/perl

though the first line of the cgi file shows as #!/usr/bin/perl

The following steps solved the problem:
1) dos2unix FILENAME  ---> resets owner and permissions
2) chown xxx:xxx FILENAME (to correct ownership)
3) chmod 775 FILENAME


Random Solutions  
 
programming4us programming4us