note 50358 added to features.commandline

From: Date: Fri, 25 Feb 2005 16:15:38 +0000
Subject: note 50358 added to features.commandline
Groups: php.notes 
Request: Send a blank email to php-notes+get-85557@lists.php.net to get a copy of this message
This posting is not a php-only problem, but hopefully will save someone a few hours of headaches. Running on MacOS (although this could happen on any *nix I suppose), I was unable to get the script to execute without specifically envoking php from the command line: [macg4:valencia/jobs] tim% test.php ./test.php: Command not found. However, it worked just fine when php was envoked on the command line: [macg4:valencia/jobs] tim% php test.php Well, here we are... Now what? Was file access mode set for executable? Yup. [macg4:valencia/jobs] tim% ls -l total 16 -rwxr-xr-x 1 tim staff 242 Feb 24 17:23 test.php And you did, of course, remember to add the php command as the first line of your script, yeah? Of course. #!/usr/bin/php <?php print "Well, here we are... Now what?\n"; ?> So why dudn't it work? Well, like I said... on a Mac.... but I also occasionally edit the files on my Windows portable (i.e. when I'm travelling and don't have my trusty Mac available)... Using, say, WordPad on Windows... and BBEdit on the Mac... Aaahhh... in BBEdit check how the file is being saved! Mac? Unix? or Dos? Bingo. It had been saved as Dos format. Change it to Unix: [macg4:valencia/jobs] tim% ./test.php Well, here we are... Now what? [macg4:valencia/jobs] tim% NB: If you're editing your php files on multiple platforms (i.e. Windows and Linux), make sure you double check the files are saved in a Unix format... those \r's and \n's 'll bite cha! ---- Manual Page -- http://www.php.net/manual/en/features.commandline.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50358 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50358&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50358&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50358&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50358&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50358&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50358&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85557) next »