Question:
How to execute a shell command within php?
The example below shows how to execute a shell command from within php script.
The command pwd
executes the current working directory.
<?php $output = shell_exec('pwd'); echo "<pre>$output</pre>"; ?>
Drupal notes
- If placed within a drupal node it will always display the base location of the drupal installation.
- If you require to call a program which resides above the drupal directory the following may be used.
<?
include("../../legacy/program.php");
?>