execute php script in command line from web page -
i'm green @ running php in command line, , need find way execute php script loading web page in browser. don't need return values, need make script run/execute. so, once "page.php" loaded in browser, script inside page.php begin running in terminal/cli.
i've tried doing adding line <?php exec('php script.php') ?>
, doesn't work. possible?
update:
provide code give insight/clarity on setup testing. can script ran putting in body below, or need called explicitly somehow?
<!doctype html> <html> <head> <meta charset="utf-8"> <title>web page</title> <link href="style.css" rel="stylesheet" type="text/css"> <?php include_once 'check_login_status.php'; ?> </head> <body> <?php exec('php /applications/xampp/htdocs/site_root/script_to_run.php'); ?> <div id = "wrapper"> <div id = "nav"><?php include_once 'navigation.php'; ?></div> <div id = "top"><?php include_once 'top.php'; ?></div> <div id = "main"></div> </div> </body> </html>
you have understand exec
doesn't have access usual environment variables in, example, ssh prompt. need provide full path php in command. like
<?php exec('/usr/bin/php script.php'); ?>
Comments
Post a Comment