Shell Script From PPH

Hypertufa Batch Mix
Poor Man's Rebar

Shell Script From PPH

# Simple PHP / Bash Shell Sample

# FOOBAR.php
# php code
echo "Running Pull.sh Shell Script";
$output = shell_exec('/html/scripts/pull.sh');
echo "<pre>$output</pre>";


# FOOBAR.sh
#!/bin/bash
touch temp/FOOBAR.txt
echo "FOO-BAR-Script-Output" > temp/FOOBAR.txt
cat temp/FOOBAR.txt

###############

# More Complex PHP / Bash
# PHP code to run script with parameter variables from page node

drupal_set_message(t('We are running a PHP rule to create a QR code for this node'));
$mynode =(token_replace('[node:nid]', array('node' => $node)));
$mytitle = $node->title;
$backgroundcolor = $node->field_background_color[0]['value'];
$foregroundcolor =$node->field_foreground_color[0]['value'];
$qrsize =$node->field_qr_size[0]['value'];
shell_exec('/opt/www/{SITENAME}/html/{SCRIPT_PATH}/qr_build_script.sh'." ".escapeshellarg($mynode)." ".escapeshellarg($mytitle)." ".escapeshellarg($backgroundcolor) ." ".escapeshellarg($foregroundcolor)." ".escapeshellarg($qrsize));