freedbill Posted April 14, 2009 Share Posted April 14, 2009 I'm trying to use PHP CLI for the first time and am encountering a path problem that has me confused. Background: I am using a Virtual dedicated server from Godaddy, running Apache Server, on Linux 2.6.9 with PHP 5.2.6 and PLESK 8.4. I know my way around Linux just enough to get into trouble. I have created the following simple php script (named tester): #!/usr/bin/php -q <? echo "Hello World"; ?> I have placed it in two locations for testing: Location one: The script is placed in /usr/bin I can execute the following command line from anywhere and it works fine: /./usr/bin/tester Location two (in a web folder): The script is placed in: /var/www/vhosts/lasmi1.net/httpdocs I am unable to execute this script from the following command line. /./var/www/vhosts/lasmi1.net/httpdocs/tester. I can 'cd' to the web folder and still am unsuccessful with the following command line: ./tester The error is 'extension "./testert is not present" ' This should be simple, but has my brain busted. Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/154089-solved-php-cli-linux-path-problem/ Share on other sites More sharing options...
gizmola Posted April 14, 2009 Share Posted April 14, 2009 Ok, so I'm not sure why you are putting the '.' (current directory) in all your paths. When you cd to a directory to attempt to run it there, it's appropriate, but not when you're running it from some other directory like: /./var/www/vhosts/lasmi1.net/httpdocs/tester That should just be /var/www/vhosts/lasmi1.net/httpdocs/tester So the first thing to check is: did you set the permissions on the script so that it has the executable bit? You can check this with "ls -lath" To set the executable bit for all users: chmod ugo+x tester Quote Link to comment https://forums.phpfreaks.com/topic/154089-solved-php-cli-linux-path-problem/#findComment-809995 Share on other sites More sharing options...
freedbill Posted April 14, 2009 Author Share Posted April 14, 2009 Boy do I wish I could just withdraw this question! Thanks so much for the simple but not so obvious to me use of dot (.) reference. I did not grasp that the dot reference was a reference to the current directory and thought that it was some sort of command needed to "execute" the php cli script. Oh well, thanks again for the obvious. All works well now. Bill Quote Link to comment https://forums.phpfreaks.com/topic/154089-solved-php-cli-linux-path-problem/#findComment-810001 Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 Sure thing. One thing that differentiates unix is that for security reasons, the current directory is not in the path. This is meant to help prevent people from inadvertently running bogus versions of common commands, rather than those in the path. For this reason, if you have a script in the current working directory, and you try and run it, it won't be found unless you add the current directory path. It's an oddity of *nix shell configuration that differs from windows and DOS who tend to include the . directory in the path, so that the current directory is searched first. At any rate, that is why you have to specify ./myscript, only when you're trying to run a script in the current directory. Quote Link to comment https://forums.phpfreaks.com/topic/154089-solved-php-cli-linux-path-problem/#findComment-810331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.