Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    ohio
    Posts
    127

    web interface for C++ program

    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

  2. #2
    Join Date
    Dec 2002
    Location
    UCIrvine, Irvine, CA
    Posts
    193
    PHP Code:
    <?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
    (: ˙pɐǝɥ ɹnoʎ uo ƃuıpuɐʇs ǝq ʇsnɯ noʎ uǝɥʇ˙˙˙sʎɐs sıɥʇ ʇɐɥʍ pɐǝɹ uɐɔ noʎ ɟI
    Picmember.com - Full Quality Event-Based Photo Sharing
    MitchDB: Gameserver Control System

  3. #3
    Join Date
    Sep 2002
    Location
    ohio
    Posts
    127

    thank you

    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?

  4. #4
    Join Date
    Dec 2002
    Location
    UCIrvine, Irvine, CA
    Posts
    193
    PHP Code:
    <?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
    (: ˙pɐǝɥ ɹnoʎ uo ƃuıpuɐʇs ǝq ʇsnɯ noʎ uǝɥʇ˙˙˙sʎɐs sıɥʇ ʇɐɥʍ pɐǝɹ uɐɔ noʎ ɟI
    Picmember.com - Full Quality Event-Based Photo Sharing
    MitchDB: Gameserver Control System

  5. #5
    Join Date
    Feb 2003
    Location
    NY
    Posts
    586
    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.

  6. #6
    Join Date
    Dec 2002
    Location
    UCIrvine, Irvine, CA
    Posts
    193
    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.
    (: ˙pɐǝɥ ɹnoʎ uo ƃuıpuɐʇs ǝq ʇsnɯ noʎ uǝɥʇ˙˙˙sʎɐs sıɥʇ ʇɐɥʍ pɐǝɹ uɐɔ noʎ ɟI
    Picmember.com - Full Quality Event-Based Photo Sharing
    MitchDB: Gameserver Control System

  7. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •