Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

Hi I have wrote a script for a webpage in python. However when I run it I seem to get this error

/usr/bin/env: python\r: No such file or directory
Premature end of script headers: users.cgi

I'm not sure what is causing it, so far I have:

  • A Shebang which is #!/usr/bin/env python
  • I also have other scripts that execute fine on the same server in the folder.
  • I have no syntax errors in the code (I've used IDLE to check)
  • The file also has 755 permissions and is owned by www-data

Could someone help me or point me in the right direction. I can't work out what is going wrong. There is very little in the apache error log. Your help will be greatly appreciated

share|improve this question

1 Answer 1

You've uploaded the file with DOS/Windows line endings. UNIX script executables have to be saved with UNIX line endings.

share|improve this answer
    
I thought that might have happened is that what the /r was? How do I change this so that it will work? – Riley May 29 '14 at 17:56
    
Right, that's what the \r is — it's part of the DOS/Windows line endings. (You're lucky that env outputs it this way; in some situations, it'll show up as a literal carriage return, which is much more confusing.) Check your text editor settings for how to fix it, or run dos2unix on the server. – duskwuff May 29 '14 at 18:20
    
If you are using a text editor to write your scripts, I recommend notepad ++ (notepad-plus-plus.org) as it is developer oriented. – NuclearPeon Jun 30 '14 at 23:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.