title: How to POST form data to a bash script from cgi file?
body: <p>I've been tasked with creating a simple page and form in Webmin that takes 5 parameters, and sends them to a bash script for further processing.</p>
  
  <p>Nothing fancy, but this is new to me, and I'm unsure how to accomplish this task.</p>
  
  <p>I'm able to manually pass parameters to my bash script like</p>
  
  <pre><code>sh mySync.sh "1.2.3.4" "user" "password" "abc" "def"
  </code></pre>
  
  <p>and they they echo out accordingly. </p>
  
  <p>Here are my files:</p>
  
  <p><strong>index.cgi</strong></p>
  
  <pre><code>#!/usr/bin/perl
  
  require 'mySync-lib.pl';
  ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
  
  $conf = get_mySync_config();
  print &amp;text('index_root', $dir),"&lt;p&gt;\n";
  
  
  print( "&lt;div class='container'&gt;" );
  print( "&lt;div class='row'&gt;" );
  print( "&lt;h3&gt;MySync&lt;/h3&gt;" );
  print( "&lt;p&gt;Use this utility to pass params to mySync.sh&lt;/p&gt;" );
  print( "&lt;form class='form-horizontal' method='POST' action='mySync.sh'&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;label for='targetServer' class='col-xs-2 control-label'&gt;Target Server&lt;/label&gt;" );
  print( "&lt;div class='col-xs-7'&gt;" );
  print( "&lt;input type='text' class='form-control' name='targetServer' id='targetServer' placeholder='Target Server'&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;label for='userName' class='col-xs-2 control-label'&gt;User Name&lt;/label&gt;" );
  print( "&lt;div class='col-xs-7'&gt;" );
  print( "&lt;input type='text' class='form-control' name='userName' id='userName' placeholder='User Name'&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;label for='password' class='col-xs-2 control-label'&gt;Password&lt;/label&gt;" );
  print( "&lt;div class='col-xs-7'&gt;" );
  print( "&lt;input type='password' class='form-control' name='password' id='password'&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;label for='srcScope' class='col-xs-2 control-label'&gt;Source Scope&lt;/label&gt;" );
  print( "&lt;div class='col-xs-7'&gt;" );
  print( "&lt;input type='text' class='form-control' name='srcScope' id='srcScope'&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;label for='destScope' class='col-xs-2 control-label'&gt;Destination Scope&lt;/label&gt;" );
  print( "&lt;div class='col-xs-7'&gt;" );
  print( "&lt;input type='text' class='form-control' name='destScope' id='destScope'&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;div class='form-group'&gt;" );
  print( "&lt;div class='col-xs-offset-2 col-xs-10'&gt;" );
  print( "&lt;button type='submit' class='btn btn-default'&gt;Send Data to mySync.sh&lt;/button&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt;" );
  
  print( "&lt;/form&gt;" );
  print( "&lt;/div&gt;" );
  print( "&lt;/div&gt; &lt;!- end of container -&gt;" );
  
  
  ui_print_footer("/", $text{'index'});
  </code></pre>
  
  <p><strong>mySync.sh</strong></p>
  
  <pre><code>#!/bin/bash
  
  echo "BASH FIELD 1:    $1"
  echo "BASH FIELD 2:    $2"
  echo "BASH FIELD 3:    $3"
  echo "BASH FIELD 4:    $4"
  echo "BASH FIELD 5:    $5"
  </code></pre>
  
  <p>Please let me know if I'm missing a step, or what the next logical step would be.
  Thanks!</p>