logo sykohpath.com

				where code goes to die
			
	
blog

Line Endings

/bin/sh: /usr/local/sbin/<filename>.php: /usr/local/bin/php^M: bad interpreter: No such file or directory

I have a php script that is run as a cron job.  I get this error when I try to run it from the command line, and this is due to line endings being saved as Windows (CRLF) instead of plain old Unix (LF).  A few methods to fix this, however, they weren't quite working - reg ex searches "completed" but didn't change them.

1) vi <filename>.php
2) :set fileformat=unix
3) :w

Magic.  This forces the file to be saved as Unix, and changes all the line endings to match.  :x and test...

./<filename>.php

No error, so cron job will work fine now!

unix,


0 comments.
Sign in to post a comment!



No comments posted yet!