Thursday, 19 September 2013

How to run script file.exp on php with date-picker parameters?

How to run script file.exp on php with date-picker parameters?

I have made ​​a part of the script but I'm stuck: This code
runs when i select the date from date-picker. I need to run file.exp with
date parameters from date-picker mm dd yyyy. I have a file report.php and
there:
<?
if (isset($_GET['debug'])) { define('DEBUG', true); }
if (isset($_GET['debug_url'])) { define('DEBUG_URL', true); }
if (defined('DEBUG')) header("Content-type: text/plain");
include "lib.php";
$date_to = $date_from = 0;
if (isset($_GET['date-from'])) { $date_from = $_GET['date-from']; }
if (isset($_POST['date-from'])) { $date_from = $_POST['date-from']; }
$date = make_date($date_from) ;
echo "$date_from";
if (preg_match('#^(\d{2})/(\d{2})/(\d{4})$#', $date_from, $matches)) {
$month = $matches[1];
$day = $matches[2];
$year = $matches[3];
} else {
echo 'invalid format';
}
echo "new day: $day";
It works ok i get new day ... but it not work with this command.
$s_command = '/full_path/file.exp
--day'.$day.'--month'.$month.'--year'.$year.'$
echo "$s_command \n";
exec($s_command, $output);
?>
In file.exp i have:
#!/usr/bin/expect -f
foreach {option value} $argv {
switch -glob -- $option {
--day {set day $value}
--month {set month $value}
--year {set year $value}
default { error "Unknown option $option!"
exit 0 }
}
}
Here is the rest of the code and we come to the command:
expect "week ending" { send "$month-$day-$year\r" }
I have to mention that using this file.exp i try to send date mm dd yyyy
to interface on telnet or tty. And also if i put date on static in this
file.exp and run it from command line it works.maybe the problem is this
global-variables(I do not understand them). Please help me :-)

No comments:

Post a Comment