RE: [PHP] Three quickies anyone?
[snip] 1. I start my CLI scripts with: #!/usr/local/etc/php as thats the path on my machine... the problem is some of these scripts will have to be installed on clients machines by them... any easy way for them to find out whats the path PHP is installed on their machine? (this q is more of a doubt really) is it the same as $_SERVER[include_path] [/snip] Have them go to the command line and type 'which php' and it will return the path. [snip] 2. This ones more of an Apache question but related to my php script and I think its safe to assume everyone on this list has worked with Apache and some have a ing good understanding of the server. Basically I am trying to pipe some data into my php script by adding this to my .htaccess file: CustomLog | /home/petpass/public_html/test/testing.php but it gives me an error as I try to access the directory where the .htaccess file is in it works perfectly fine when/if I add the exact same directive in my httpd.conf file though so, does the format need to be changed in some way to add it to my .htaccess file or is it simply not allowed in the htaccess file? [/snip] What are the permissions of the directory? [snip] 3. This should be a rather simple question but I just confused myself after reading/searching google (i do that to myself sometimes, totally unintentional really) Can I run CLI/Shell scripts eg: scripts that began with the #!php path on machines that have PHP loaded as a CGI and as a module or only as a CGI or only as a module? [/snip] I have actually used PHP to run scripts from the command line like this before the CLI version came out. As long as the path is correct you shouldn't have a problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Three quickies anyone?
Hey Jay, [snip] is it the same as $_SERVER[include_path] [/snip] Have them go to the command line and type 'which php' and it will return the path. The clients will probably not even understand what command line means, I was thinking of doing something like this: ask the client to enter the path to php on his server, if he does not know the path then to download the script get_php_path.php from my site that would contain ?php echo The path to php on your server is: .$_SERVER[include_path]; ? then they would then enter that valuebut is $_SERVER[include_path]; the correct thing to use? [/snip] so, does the format need to be changed in some way to add it to my .htaccess file or is it simply not allowed in the htaccess file? [/snip] What are the permissions of the directory? The permissions are 755...but thanks for the tip, for some reason it didnt strike me that it might be a permissions issue.., will check other permissions and get back to you/the list if it still does not work. The thing is, its not actually writing anything there...I just want it to call the php script to process the data there.. [snip] 3. [/snip] I have actually used PHP to run scripts from the command line like this before the CLI version came out. As long as the path is correct you shouldn't have a problem. Thats a relief, thanks! Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Three quickies anyone?
Ryan A wrote: Hey, I am new to CLI and using PHP to run shell but need to know it so am getting my feet wet, hopefully with your help :-) Now when I said three quickies, I mean three PHP RELATED quickies of course...if you thought anything otherwise... you have a wicked mind. Here goes: 1. I start my CLI scripts with: #!/usr/local/etc/php as thats the path on my machine... the problem is some of these scripts will have to be installed on clients machines by them... any easy way for them to find out whats the path PHP is installed on their machine? (this q is more of a doubt really) is it the same as $_SERVER[include_path] The canonical way: #!/usr/bin/env php This will call the first php executable in $PATH, and is generally used when portability in scripts is desired. 3. This should be a rather simple question but I just confused myself after reading/searching google (i do that to myself sometimes, totally unintentional really) Can I run CLI/Shell scripts eg: scripts that began with the #!php path on machines that have PHP loaded as a CGI and as a module or only as a CGI or only as a module? Well, if you use the canonical way I describe above, one problem I foresee is that the cgi-bin directory is hardly ever in $PATH. . . HTH, Kevin Kinsey -- How many people work here? Oh, about half. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Three quickies anyone?
Ryan A wrote: Have them go to the command line and type 'which php' and it will return the path. The clients will probably not even understand what command line means, I was thinking of doing something like this: ask the client to enter the path to php on his server, if he does not know the path then to download the script get_php_path.php from my site that would contain ?php echo The path to php on your server is: .$_SERVER[include_path]; ? then they would then enter that valuebut is $_SERVER[include_path]; the correct thing to use? Why don't you use the inbuild shell function of php to get the info from PHP itself? http://de3.php.net/manual/de/function.escapeshellcmd.php Since you can echo that also. I just forgot what command it was but probably it helps you anyways :) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Three quickies anyone?
The canonical way: #!/usr/bin/env php Thanks Kevin, Well, if you use the canonical way I describe above, one problem I foresee is that the cgi-bin directory is hardly ever in $PATH. . . Will keep that in mind.. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Three quickies anyone?
Ryan A wrote: ... 1. I start my CLI scripts with: #!/usr/local/etc/php as thats the path on my machine... the problem is some of these scripts will have to be installed on clients machines by them... any easy way for them to find out whats the path PHP is installed on their machine? (this q is more of a doubt really) is it the same as $_SERVER[include_path] I don't think I even have a $_SERVER[include_path], I certainly wouldn't count on it pointing to the php binary. As another user pointed out, `which php` is probably the safest way. If you are concerned about a simple method for clients, a quick bash script which finds php and adds the appropriate line to the top of the file would be simple. Getting them to install a webpage to find out where the php binary is seems excessive. 2. This ones more of an Apache question but related to my php script and I think its safe to assume everyone on this list has worked with Apache and some have a ing good understanding of the server. Basically I am trying to pipe some data into my php script by adding this to my .htaccess file: CustomLog | /home/petpass/public_html/test/testing.php but it gives me an error as I try to access the directory where the .htaccess file is in it works perfectly fine when/if I add the exact same directive in my httpd.conf file though so, does the format need to be changed in some way to add it to my .htaccess file or is it simply not allowed in the htaccess file? The logging directives including CustomLog can't be set in the .htaccess file. You can set it in the server config or in a virtual host config. 3. This should be a rather simple question but I just confused myself after reading/searching google (i do that to myself sometimes, totally unintentional really) Can I run CLI/Shell scripts eg: scripts that began with the #!php path on machines that have PHP loaded as a CGI and as a module or only as a CGI or only as a module? You can use the CGI executable to execute shell scripts however you will get http headers like Content-type: and HTML versions of output from a few functions such as phpinfo. You can't execute scripts using the Apache module. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php