[PHP] How to access a program outside of PHP?
Hi. I'm trying to develop a web interface to the ghostscript (gs) application. I have the ghostscript syntax down perfectly in the console. Now when I go to try and do it in PHP I get nothing. No errors, nothing just a blank page with PHP logs turned on and errors turned on. I'm running Apache with PHP 4.3.3 on OpenBSD 3.3 i386. In my case Apache (httpd) is chrooted to /var/htdocs/. So I figured I would have to copy ghostscript and all it's dependencies to /var/htdocs/ at least for it to work. Still nothing. Here's the code I used below. At this point I do not know what direction to go to get this to work or if it is even possible. I've tried exec(), system() and popen() api functions. I get nothing no results, no errors what so ever. BTW, ghostscript does appear to work fine in the chrooted directory via the console. At this point the below code is all I have. The syntax for ghostscript shown below just outputs the data of the 2 PDF files to the pdfwrite so it will merge them together into a merged.pdf file. Quite simple actually. $szPipe = popen("/htdocs/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf /htdocs/Sep08-113523.pdf", "r"); I tried resulting to something simple to get this to work. I took the example from the PHP manual system() page (http://www.php.net/manual/en/function.system.php). In this example is it suppose to return "Last Line of Output: " and "Return value: 127"? This occurs with system() and passthru(). I thought it should return the last line of a ls would show in the console. Any ideas or direction on how to do this would be greatly appreciated. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
> 1) please try $szPipe and see if you get any output. > 2) if you are jailed in /var/htdocs/ your pathname /htdocs/qs > is incorrect. > 3) I guess you tried running gs from the jail either as > yourself or as > root. > please see if nobody or apache (the webserver's user) can run > gostscript. 1) When I echo out $szPipe I get "Resource id #2". 2) Oops, that chrooted in /var/www/. So I thought I should be putting just a /htdocs/, no? 3)Yes I tried running gs in the console as root works fine and as myself and that works fine. The user is www that runs httpd. How could I test to see if www has access? To my understanding such accounts can not be used to log in with. I have chown the /htdocs/ to be www:. > >Hi. I'm trying to develop a web interface to the ghostscript (gs) > >application. I have the ghostscript syntax down perfectly in > the console. > >Now when I go to try and do it in PHP I get nothing. No > errors, nothing just > >a blank page with PHP logs turned on and errors turned on. > > > >I'm running Apache with PHP 4.3.3 on OpenBSD 3.3 i386. In my > case Apache > >(httpd) is chrooted to /var/htdocs/. So I figured I would > have to copy > >ghostscript and all it's dependencies to /var/htdocs/ at > least for it to > >work. Still nothing. Here's the code I used below. At this > point I do not > >know what direction to go to get this to work or if it is > even possible. > >I've tried exec(), system() and popen() api functions. I get > nothing no > >results, no errors what so ever. BTW, ghostscript does > appear to work fine > >in the chrooted directory via the console. At this point the > below code is > >all I have. The syntax for ghostscript shown below just > outputs the data of > >the 2 PDF files to the pdfwrite so it will merge them together into a > >merged.pdf file. Quite simple actually. > > > >$szPipe = popen("/htdocs/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite > >-sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf > >/htdocs/Sep08-113523.pdf", "r"); > > > >I tried resulting to something simple to get this to work. I took the > >example from the PHP manual system() page > >(http://www.php.net/manual/en/function.system.php). In this > example is it > >suppose to return "Last Line of Output: " and "Return value: > 127"? This > >occurs with system() and passthru(). I thought it should > return the last > >line of a ls would show in the console. > > > >Any ideas or direction on how to do this would be greatly > appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
> > Hi. I'm trying to develop a web interface to the ghostscript (gs) > > application. I have the ghostscript syntax down perfectly > in the console. > > Now when I go to try and do it in PHP I get nothing. No > errors, nothing > just > > a blank page with PHP logs turned on and errors turned on. > > Does the Apache user have permission to run this program? PHP > runs as the > Apache user when installed as a module. It should. I've moved the gs and all dependencies into /var/www/htdocs/. I've ran it from that location and it seems to work fine. Also I've chowned the /htdocs/ to be www:www. Should have all the rights it needs. Apache/HTTPD runs as www. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
> >1) When I echo out $szPipe I get "Resource id #2". > > > Sorry i was thinking of backticks. btw have you tried it ? > (backticks) Backticks? Is this a PHP API function, I can't find it? That's the thing here I haven't been able to get things to work and I have no clue what I should use, exec(), system(), popen(), etc. gs just needs to be run, I do not require any output back from it other than if I can determine if it's been ran or not (true/false). > >3)Yes I tried running gs in the console as root works fine > and as myself and > >that works fine. The user is www that runs httpd. How could > I test to see if > >www has access? To my understanding such accounts can not be > used to log in > >with. I have chown the /htdocs/ to be www:. > > > can't login yes. but you can try: sudo -u www /htdocs/gs Okay, tried that and yes it worked. Any more ideas? Is there any logs I could look at to find out more, I've looked around but haven't found anything as of yet. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP-General List post bounces???
Why do I keep getting this? > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 10, 2003 10:12 AM > To: [EMAIL PROTECTED] > Subject: [ERR] RE: [PHP] How to access a program outside of PHP? > > > Transmit Report: > > To: [EMAIL PROTECTED], 402 Local User Inbox Full > ([EMAIL PROTECTED]) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
> Backticks is simply the ` sign (usually the character above the tab). > Popularly know as `hair on the ear` in my country :-) > for example if you want to invoke ls from php you just type > > $result = `ls`; > > hey presto the output from ls is now in your $result variable. Ohhh okay. Well if you mean to do this, $szPipe = popen(`/htdocs/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf /htdocs/Sep08-113523.pdf`, "r");. This does not seem change anything. If I do this with the system() example, I get "Warning: system(): Cannot execute a blank command in /htdocs/index.php on line 14". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
Mmm... okay. I tried that and nothing. Is there no way for me to determine what the problem is? Error message some place, log file, etc? I do not understand why this is not work. Even a simple example from the PHP manual on system() does not work. > I meant to do this: > > $szPipe = `/htdocs/gs -q > -dNOPAUSE -dBATCH -sDEVICE=pdfwrite > -sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf > /htdocs/Sep08-113523.pdf`; > > >>Backticks is simply the ` sign (usually the character above > the tab). > >>Popularly know as `hair on the ear` in my country :-) > >>for example if you want to invoke ls from php you just type > >> > >>$result = `ls`; > >> > >>hey presto the output from ls is now in your $result variable. > >> > >> > > > >Ohhh okay. Well if you mean to do this, $szPipe = > popen(`/htdocs/gs -q > >-dNOPAUSE -dBATCH -sDEVICE=pdfwrite > >-sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf > >/htdocs/Sep08-113523.pdf`, "r");. This does not seem change > anything. If I > >do this with the system() example, I get "Warning: system(): > Cannot execute > >a blank command in /htdocs/index.php on line 14". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to access a program outside of PHP?
No I have Safe_Mode = off. I also have error_reporting = E_ALL and display_errors = on and I have php errors to log to a log file. I have no log file of php errors nor is there an error being display on the page. Geez this is frustrating, yeah that's what I figure but you would think there can be something done about this or at least get some error message to determine what is going on. > btw have you checked if you are in safe_mode? in php.ini > error level can also be set in php.ini > > my guess is that you have a problem in your chroot setup. > Adam Douglas wrote: > > >Mmm... okay. I tried that and nothing. Is there no way for > me to determine > >what the problem is? Error message some place, log file, > etc? I do not > >understand why this is not work. Even a simple example from > the PHP manual > >on system() does not work. > > > > > > > >>I meant to do this: > >> > >>$szPipe = `/htdocs/gs -q > >>-dNOPAUSE -dBATCH -sDEVICE=pdfwrite > >>-sOutputFile=/htdocs/merged.pdf /htdocs/Sep08-113518.pdf > >>/htdocs/Sep08-113523.pdf`; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 4.3.3 Install, Errors??
Hi. I have a machine that's been freshly installed with PHP 4.1.1. I wanted to upgrade it to PHP 4.3.3. So I did the following below as SU and received the below errors. Is this something I should be worried about? How can I resolve the errors? Never have had this happen before in the past. I ran phpinfo() and it shows PHP 4.3.3, but is the install of PHP okay? If you require any additional information let me know, thanks! # make install Installing PHP CLI binary:/usr/local/bin/ Installing PHP CLI man page: /usr/local/man/man1/ Installing PHP SAPI module: apache [activating module `php4' in /var/www/conf/httpd.conf] cp libs/libphp4.so /usr/lib/apache/modules/libphp4.so chmod 755 /usr/lib/apache/modules/libphp4.so cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf rm /var/www/conf/httpd.conf.new Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20020429/ Installing PEAR environment: /usr/local/lib/php/ Parse error: parse error in /usr/files/storage/Software/php-4.3.3/pear/package-Archive_Tar.xml on line 1 *** Error code 255 Stop in /usr/files/storage/Software/php-4.3.3 (line 263 of Makefile). *** Error code 1 Stop in /usr/files/storage/Software/php-4.3.3 (line 269 of Makefile). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP 4.3.3 Install, Errors??
I finally have my installation of PHP 4.3.3 to work, thanks to your help and a couple other people on IRC. For knowledge sack here's how I resolve the problem. Installed port/packages of... png-1.2.5p1 jpeg-6b gd-1.8.3 (built in library of PHP would not work for me) ImageMagick-5.2.9 zlib (build in. standard part of OpenBSD, /usr/lib/) To resolve the "config: error: fix png.h not found." error I was unable to do this without making a symbolic link. cd /usr/local/include; ln -s libpng/*. This would crate a symbolic link of each file in /usr/local/include/libpng in /usr/local/include. Than run configure, and everything was just fine. ./configure --with-mysql --with-xml --with-apxs --without-pear --with-config-file-path=/var/www/conf --with-zlib --with-zlib-dir=/usr --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-gd=/usr/local make make install Thanks for the help! > Unless you need PEAR, you're fine. Try configuring > --without-pear. You should > really be doing this anyways unless actually need PEAR. > > Evan Nemerson > > > On Thursday 11 September 2003 02:10 pm, Adam Douglas wrote: > > Hi. I have a machine that's been freshly installed with PHP > 4.1.1. I wanted > > to upgrade it to PHP 4.3.3. So I did the following below as > SU and received > > the below errors. Is this something I should be worried > about? How can I > > resolve the errors? Never have had this happen before in > the past. I ran > > phpinfo() and it shows PHP 4.3.3, but is the install of PHP okay? > > > > If you require any additional information let me know, thanks! > > > > > > # make install > > Installing PHP CLI binary:/usr/local/bin/ > > Installing PHP CLI man page: /usr/local/man/man1/ > > Installing PHP SAPI module: apache > > [activating module `php4' in /var/www/conf/httpd.conf] > > cp libs/libphp4.so /usr/lib/apache/modules/libphp4.so > > chmod 755 /usr/lib/apache/modules/libphp4.so > > cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak > > cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf > > rm /var/www/conf/httpd.conf.new > > Installing shared extensions: > > /usr/local/lib/php/extensions/no-debug-non-zts-20020429/ > > Installing PEAR environment: /usr/local/lib/php/ > > > > Parse error: parse error in > > > /usr/files/storage/Software/php-4.3.3/pear/package-Archive_Tar > .xml on line > > 1 *** Error code 255 > > > > Stop in /usr/files/storage/Software/php-4.3.3 (line 263 of > Makefile). > > *** Error code 1 > > > > Stop in /usr/files/storage/Software/php-4.3.3 (line 269 of > Makefile). > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Initially Does Work
Hi. I've run into a problem with my PHP session. I'm running PHP 4.1.0 on OpenBSD v3.0 using .HTACCESS and mod_mysql. I have a PHP file that is referenced every time content is requested on the web site (this file also sets/restores the session). This PHP file includes [include()] the requested content within. When my session is created I register 6 variables. The problem comes into play when you want to access one of the 6 registered variables on the initial page (after the user logs in). For some reason the registered variables are not recognized. I'm accessing the register variables using $_SESSION[variable_name]. I've also assigned values to these variables. The funny thing about the whole issue is if you reload/refresh the page or load something else after the initial page everything works fine. I require this to work initially because if someone comes in directly using a link certain content will render a error message because the registered variable is not present for some reason. Oh and yes the cookie to set the session is being put on the client's machine properly and at the initial page. Am I doing something wrong? Any suggestions would be greatly appreciated! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Initially Does Work
I already have this setup. The session works just not on the initial page after login. > Add > > At the top of each page, before anything else is done. > > -Original Message----- > From: Adam Douglas [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 01, 2002 3:15 PM > To: PHP-General (mailing list) (E-mail) > Subject: [PHP] Session Initially Does Work > > > Hi. I've run into a problem with my PHP session. I'm running PHP > 4.1.0 on OpenBSD v3.0 using .HTACCESS and mod_mysql. I have a > PHP file that > is referenced every time content is requested on the web site > (this file > also sets/restores the session). This PHP file includes > [include()] the > requested content within. When my session is created I > register 6 variables. > The problem comes into play when you want to access one of > the 6 registered > variables on the initial page (after the user logs in). For > some reason the > registered variables are not recognized. I'm accessing the register > variables using > $_SESSION[variable_name]. I've also assigned values to these > variables. The > funny thing about the whole issue is if you reload/refresh > the page or load > something else after the initial page everything works fine. > I require this > to work initially because if someone comes in directly using > a link certain > content will render a error message because the registered > variable is not > present for some reason. Oh and yes the cookie to set the > session is being > put on the client's machine properly and at the initial page. > > Am I doing something wrong? Any suggestions would be greatly > appreciated! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Initially Does Work
> > something else after the initial page everything works fine. I > > require this > > to work initially because if someone comes in directly using a > > link certain > > content will render a error message because the registered > variable is not > > present for some reason. Oh and yes the cookie to set the > session is being > > put on the client's machine properly and at the initial page. > When do you set the session cookie? Keep in mind cookies > don't not function > in the same call they are created so say you create the > cookie on page > A, until the user refreshes page A or goes to page B the cookie won't > actually be in effect. Well the cookie is set at the start of the PHP file that gets referenced each time. I'm not setting any manual cookies just using the default session cookie set by PHP. Below is all the code I use for the session. Formatting is kind of goofed up in e-mail but it's there. So even though the cookie is placed in the client's browser it's not used/session is not used or recognized until you refresh/reload or go to another page?? -- Code Snippet -- session_name("sid"); $nSession = session_start(); if(isset($REMOTE_USER)) { if(!$nSID_PeopleID) { $szQuery = "SELECT WebAccounts.People_ID, WebAccounts.Security_Level, People.Status_Type_ID, Company.Company_Status_ID FROM WebAccounts, People, Company WHERE WebAccounts.People_ID=People.People_ID AND People.Company_ID=Company.Company_ID AND User_Name='$REMOTE_USER'"; $szDBConn = mysql_connect("server_address","user_name","password") or die("could not connect to server for security authentication."); mysql_select_db("venmar", $szDBConn) or die("could not connect to venmar for security // authentication."); $saResults = mysql_query($szQuery, $szDBConn) or die ("could not query venmar for security authentication."); $obResults = mysql_fetch_row($saResults); $nSID_PeopleID = $obResults[0]; $nSID_SecurityLevel = $obResults[1];$nSID_PeopleStatus = $obResults[2]; $nSID_CompanyStatus = $obResults[3]; $szQuery1 = "SELECT PeopleMailing.Country_ID FROM PeopleMailing, WebAccounts WHERE WebAccounts.People_ID=PeopleMailing.People_ID AND WebAccounts.User_Name='$REMOTE_USER'"; $dbConnection = mysql_connect("server_address", "user_name", "password") or die("could not connect to server for security authentication."); mysql_select_db("venmar", $szDBConn) or die("could not connect to venmar for security authentication."); $saResults1 = mysql_query($szQuery1, $szDBConn) or die ("could not query venmar for security authentication."); $obResults1 = mysql_fetch_row($saResults1); $nSID_Country = $obResults1[0]; if(!$obResults1[0]) { $szQuery1 = "SELECT Company.Country_ID FROM Company, WebAccounts, People WHERE WebAccounts.People_ID=People.People_ID AND People.Company_ID=Company.Company_ID AND WebAccounts.User_Name='$REMOTE_USER'"; $saResults1 = mysql_query($szQuery1, $szDBConn) or die ("could not query venmar for security authentication (24)."); $obResults1 = mysql_fetch_row($saResults1); $nSID_Country = $obResults1[0]; } mysql_close(); if($obResults[2] == 1 && $obResults[3] == 1) { if($nSession == 1) { session_register("nSession"); session_register("nSID_PeopleID"); session_register("nSID_SecurityLevel"); session_register("nSID_PeopleStatus"); session_register("nSID_CompanyStatus"); session_register("nSID_Country"); $szQuery = "SELECT First_Login, Last_Login, Creation_Date FROM WebAccounts WHERE User_Name='$REMOTE_USER'"; $dbConnection = mysql_connect("server_address", "user_name", "password") or die("could not connect to server for security authentication."); mysql_select_db("venmar", $dbConnection) or die("could not connect to venmar for security authentication."); $saResults = mysql_query($szQuery, $dbConnection) or die ("could not query venmar for security authentication."); $obResults = mysql_fetch_row($saResults); if($obResults[0] == 00)
RE: [PHP] Session Initially Does Work
> That's correct, although the cookie will remain resident it > requires an > inital page change/refresh. However after looking at your > code I'm not > convinced that is the problem since the first page of a > session creation > should still be usable with the session as the session ID is > still resident > in memory. Have you tried running the page w/o the use of > session_name()? Alright that's good to hear. In a specific case that I'm having this problem the main PHP file is including file (content) that refers to $_SESSION[nSID_PeopleID] in main. This value is vital in rendering the page. So it should be there right? Also about removing session_name(), how can I do this. It was my understanding that you must call session_name before session_start() and session_register(). Is this not correct? > Also as an FYI $REMOTE_USER is an unsecure variable to use for checking > authentication. Basically because a url parameter will overwrite the > original $REMOTE_USER. > > easiest method (for me anyways) is: > > $REMOTE_USER = getenv('REMOTE_USER'); Yes I've never felt good about using REMOTE_USER. I will implement that idea right now, thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Initially Does Work
> There is a session problem with 4.1 > > If register_globals is ON, then use session_register(). > > If it's off, then use $_SESSION["name"] = "value"; and the value will > automatically be registered. What kind of session problem? I currently have register_globals set to on. I am already using session_register(). > > Hi. I've run into a problem with my PHP session. I'm running PHP > > 4.1.0 on OpenBSD v3.0 using .HTACCESS and mod_mysql. I have > a PHP file > > that > > is referenced every time content is requested on the web site (this > file > > also sets/restores the session). This PHP file includes [include()] > the > > requested content within. When my session is created I register 6 > > variables. > > The problem comes into play when you want to access one of the 6 > > registered > > variables on the initial page (after the user logs in). For some > reason > > the > > registered variables are not recognized. I'm accessing the register > > variables using > > $_SESSION[variable_name]. I've also assigned values to these > variables. > > The > > funny thing about the whole issue is if you reload/refresh > the page or > > load > > something else after the initial page everything works > fine. I require > > this > > to work initially because if someone comes in directly using a link > > certain > > content will render a error message because the registered > variable is > not > > present for some reason. Oh and yes the cookie to set the session is > being > > put on the client's machine properly and at the initial page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Initially Doesn't Work
> > Alright that's good to hear. In a specific case that I'm having > > this problem > > the main PHP file is including file (content) that refers to > > $_SESSION[nSID_PeopleID] in main. This value is vital in > > rendering the page. > > So it should be there right? Also about removing > session_name(), how can I > > do this. It was my understanding that you must call > session_name before > > session_start() and session_register(). Is this not correct? > > Ahhh, so that's your problem thenthe include isn't > getting the session > id. I've never used an include with a session setup before > but I would see > the easiest thing to do be have the include first echo the > session id number > and see if it is actually getting passed or not on the first call > > echo session_id(); Yuppers. I played around with the echo session_id(); and found it was not getting into the scope of the included file. So I removed all session_register() and replaced it with $_SESSION['varname'] = 'value'; and it solve the problem. Your not suppose (not recommended) to use session_register() anways, right? Thanks for the help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php