Closed Thread Icon

Preserved Topic: Possible to execute a c++ program, complete with switches, from CGI/Perl script? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21132" title="Pages that link to Preserved Topic: Possible to execute a c++ program, complete with switches, from CGI/Perl script? (Page 1 of 1)" rel="nofollow" >Preserved Topic: Possible to execute a c++ program, complete with switches, from CGI/Perl script? <span class="small">(Page 1 of 1)</span>\

 
silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 10-05-2002 01:12

I was wondering if it was possible to call a c++ executable, including command line switches, through CGI/Perl or SSI?

What I'm trying to do is have a page generated using a text file spit out by the executable. For example, I want to execute the program like so:
# ./createfile.out -sw1 -sw2

This would then create:
example.txt

And I can have Perl read the text file and display a page appropriately?

If I haven't explained this well, let me know.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-05-2002 01:23

sure just use a system call
system("/use/thefull/path/createfile.out -sw1 -sw2");

You can also use this with a variable to change the switches.

In terms of reading the output just use the normal perl file operators

open(IN, "< example.txt") or die "Couldn't open example.txt: $!\n";
while (<IN> ) {
print $_;
}
close(IN);


php is perhaps even easier
exec("./createfile.out -sw1 -sw2");
include("example.txt");



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 10-05-2002).]

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 10-05-2002 05:05

also, keep in mind what system this program will be running in, whether you're running a script or a compiled piece, and whether you'll allowed to run executables in your webspace...


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 10-05-2002 06:26

Hey guys, thanks loads, that was exactly what I needed.

« BackwardsOnwards »

Show Forum Drop Down Menu