Re: Executing a PHP file to write an html file

From: Date: Mon, 02 Apr 2001 01:25:53 +0000
Subject: Re: Executing a PHP file to write an html file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-46536@lists.php.net to get a copy of this message
If you have the php cgi installed you can run a script like so: exec("php -q /path/to/script.php") You didn't include the command (php -q), you only included the path to the script. If you don't have the cgi, but you are running on *nix you can exec("lynx http://www.host.com/script.php") assuming lynx is installed. Instead of exec, why not just include the script you want to run in your page? Matt Friedman Spry New Media http://www.sprynewmedia.com ----- Original Message ----- From: "David Robley" <huntsman@www.nisu.flinders.edu.au> To: "PHP User" <phpuser@chek.com>; <php-general@lists.php.net> Sent: Sunday, April 01, 2001 5:53 PM Subject: Re: [PHP] Executing a PHP file to write an html file > On Sun, 1 Apr 2001 03:06, PHP User wrote: > > Here is my problem. > > I have a file, static.php > > static.php writes to index.html by way of... > > $filename = "/web/h16/docs/index.html"; > > $fp = fopen("$filename","w"); > > fwrite($fp, "<table width=\"230\">\n"); > > etc...... > > > > If I hit static.php from the command line, index.html gets written just > > fine. static.php does it's job. > > > > If I try to exec(), or system() static.php from a browser the browser > > just hangs. eg. I add: > > system ('/usr/local/bin/php web/h16/docs/index.html); > > or > > exec ('/usr/local/bin/php web/h16/docs/index.html); > > To a file and get nothing. I tried with and without the absolute paths > > in the commands. > > > > What I want to be able to do is every time I update a Db, at the same > > time I want the index page to be rewritten to reflect the changes in > > the Db. And I don't want to have to go to the command line everytime I > > want to rewrite the index page. So I would just hit "SAve" in the > > update.php page, it would save to the Db, which it does now, and at the > > same time it hits static.php and therefore rewrites index.html > > > > I also tried header() but that was no good due to echo in the pages, > > gives that header already sent error. > > > > Is there a funtion I am missing somehwere that does the job? > > > > It's a Unix box running php 4.03, and the Db is MySQL > > > > Thanks Much!! > > Is it possible you have a permissions problem? Remember that your > webserver will probably be running as something like nobody, which may > not have the necessary permissions to wwrite to files in that particular > directory. > > > -- > David Robley | WEBMASTER & Mail List Admin > RESEARCH CENTRE FOR INJURY STUDIES | > http://www.nisu.flinders.edu.au/ > AusEinet | > http://auseinet.flinders.edu.au/ > Flinders University, ADELAIDE, SOUTH AUSTRALIA > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#46536) next »