You're welcome. I've used it to run qqwing - a command line sudoku utility. It can output various things. But with a PHP page like:
PHP Code:
<?php
exec('qqwing --generate --solution', $output);
echo '<pre>';
echo preg_replace('#^$#m', '<div style="display:none;">', implode("\n", $output));
echo '</div></pre>';
?>
You get a page in the browser that looks something like (the exact puzzle is different every time):
Code:
. . 7 | . . 8 | . . .
. 2 . | 5 . . | . . 7
. . 9 | 2 4 . | . . .
-------|-------|-------
4 9 . | . 8 . | 6 . .
. . 2 | . 5 . | . 8 .
. . . | . . 6 | 4 7 2
-------|-------|-------
. 6 . | . . . | . . 5
. 5 . | . 9 . | . . .
7 . . | 1 . . | . . .
and a display: none; div with this (the solution) in it:
Code:
5 4 7 | 3 6 8 | 1 2 9
8 2 6 | 5 1 9 | 3 4 7
3 1 9 | 2 4 7 | 5 6 8
-------|-------|-------
4 9 3 | 7 8 2 | 6 5 1
6 7 2 | 4 5 1 | 9 8 3
1 8 5 | 9 3 6 | 4 7 2
-------|-------|-------
9 6 1 | 8 7 4 | 2 3 5
2 5 8 | 6 9 3 | 7 1 4
7 3 4 | 1 2 5 | 8 9 6
The qqwing options are:
Code:
qqwing <options>
Sudoku solver and generator.
--generate <num> Generate new puzzles
--solve Solve all the puzzles from standard input
--difficulty <diff> Generate only simple,easy, intermediate, or expert
--puzzle Print the puzzle (default when generating)
--nopuzzle Do not print the puzzle (default when solving)
--solution Print the solution (default when solving)
--nosolution Do not print the solution (default when generating)
--stats Print statistics about moves used to solve the puzzle
--nostats Do not print statistics (default)
--count-solutions Count the number of solutions to puzzles
--nocount-solutions Do not count the number of solutions (default)
--history Print trial and error used when solving
--nohistory Do not print trial and error to solve (default)
--instructions Print the steps (at least 81) needed to solve the puzzle
--noinstructions Do not print steps to solve (default)
--log-history Print trial and error to solve as it happens
--nolog-history Do not print trial and error to solve as it happens
--one-line Print puzzles on one line of 81 characters
--compact Print puzzles on 9 lines of 9 characters
--readable Print puzzles in human readable form (default)
--csv Ouput CSV format with one line puzzles
--help Print this message
--about Author and license information
--version Display current version number
So you see that you can get the output from the program as specified by the options you invoke it with, and then 'massage' that output for your purposes.
For something like a command line anti-virus program, options might be something like (if it can scan inside of zipped files):
Code:
/scan /file:whatever.zip
If so you could do in your PHP page (if the program is called antivirus.exe):
PHP Code:
<?php
$file = 'whatever.zip';
exec('antivirus /scan /file:' . $file, $output);
?>
You would then have the output in the $output variable. qqwing is incredibly fast, so for a scan, you might need something like usleep:
http://us2.php.net/manual/en/function.usleep.php
Perhaps (obviously untested):
PHP Code:
<?php
$file = 'whatever.zip';
exec('antivirus /scan /file:' . $file, $output);
while (!isset('$output')) usleep(10000);
echo $output; // and/or do something else with the output
?>
Bookmarks