Web Hosting Talk







View Full Version : web interface for C++ program


xaero
09-27-2003, 06:03 PM
does anyone know how i could write a web interface that will all the user to start and stop a c++ program and to enter the server ip address,and show the ouput of the program.

i need this interface for a UDP repeater that myself and some other students are using to broadcast game server's udp broadcasts across VLANS at out university. If anyone knows how to write a web interface that could do that please let me know and ill send your the client and the server source code of the repeater.

email me at pauljusm@notes.udayton.edu

CSD_Hosting
09-27-2003, 07:31 PM
<?php

// Executes system commands
// and displays output
function docommand($command) {
$out = "=============\nOutput\n=============\n\n";
if (!($p=popen("($command)2>&1","r"))) {
return 126;
}

while (!feof($p)) {
$line=fgets($p,1000);
$out .= $line;
$out .= "<br>";
}
pclose($p);
return $out;
}

$command = "netstat -a -n";

echo docommand($command);
// This command executes whatever
// is inside $command, and then
// displays ALL of the output of that
// specific command
// for your app just make
// $command = "yourapp.exe -parameters";

// Mitchell Dempsey
// webdestroya at cox dot net

?>

Note: This command will work on both linux and win32 machines

xaero
09-27-2003, 08:41 PM
thank you, but i was wondering is there any way to pass the command options, like the ip address of the master server is added to the program by passing the program the -s 131.238.x.x option. Is there anyway to do that, and anyway to send an end signal to the program like a ctrl ^c from the linux command line, and make it an option button?

CSD_Hosting
09-27-2003, 08:47 PM
<?php

// Executes system commands
// and displays output
function docommand($command) {
$out = "=============\nOutput\n=============\n\n";
if (!($p=popen("($command)2>&1","r"))) {
return 126;
}

while (!feof($p)) {
$line=fgets($p,1000);
$out .= $line;
$out .= "<br>";
}
pclose($p);
return $out;
}

$command1= "netstat -s 131.238.x.x";
$command = "yourproggie.exe -ip ";

$command .= docommand($command1);
// adds the IP to the end of the command

$realcommand = docommand($command);
// This command executes whatever
// is inside $command, and then
// displays ALL of the output of that
// specific command
// for your app just make
// $command = "yourapp.exe -parameters";

// Mitchell Dempsey
// webdestroya at cox dot net


?>



As for CTRL^C and whatnot, im not really sure what you would do, but this command doesnt leave programs running, it displays output after the program has closed, so if you have an infinite loop, you will never see output, infact, the page will never stop loading. you would have to make some sort of service
and use start and stop commands, and make a graphical web
interface to send the service commands

Jake Weg
10-01-2003, 02:18 PM
how does cpanel do it where it loads the script and provides hte output as the script does. or for that matter the tracert/ping scripts I see.

CSD_Hosting
10-01-2003, 06:01 PM
proc_open() i believe, but im not sure, i know the code i pasted above will work on *nix machines, so u can use that.