0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

I thought that might have happened is that what the /r was? How do I change this so that it will work?
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.
If you are using a text editor to write your scripts, I recommend notepad ++ (notepad-plus-plus.org) as it is developer oriented.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.