R
rallabs
Dear perl experts:
I am having some difficulties with the 'system' command. I am trying
to use it to run a C
program that has already been compiled. If I am at the UNIX command
prompt I can run the program by typing in "~/runsgood.exe". The
program then prompts me for an input file for it to use. It says:
ENTER INPUT FILE NAME WITHOUT .in EXTENSION. and when I obey I get
nothing at the prompt except there will be
a new file in my current directory with the same root as I gave it but
a .out extension. I can also run the program by preparing a file
containing the root name including the path: ~/runsgood.exe<point. The
file "point" is a single
line: ~/directory/root . When I run the program this way I see the
prompt but the program gets its answer from the file "point". The
problem is it doesn't do this from the sys command. Here is the script
I use to try it:
#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qwstandard -no_xhtml);
use diagnostics;
my $co = new CGI;
my $newID=cookie('newID');
system "sed s/old/$newID/ point_old >point.$newID";
system "~/runsgood.exe<point.$newID";
print $co->redirect('~/cgi-bin/done.cgi');
and when I run the script here's what appears in a browser window:
ENTER INPUT FILE NAME WITHOUT .in EXTENSION
Status: 302 Moved
Location: ~/cgi-bin/done.cgi
The prompt from runsgood.exe appears, just as it does when I run it
interactively. The program does its job and the output does appear in
my directory as it should, but it cannot get to the last line for some
reason. Does anybody know how to stop this? I was hoping that I would
get the prompt to disappear because I had no header in the script, and
I hoped that it would move on to the script 'done.cgi' but no such
luck. I need to find a way to get to that last script. Thanks for any
help.
mike
I am having some difficulties with the 'system' command. I am trying
to use it to run a C
program that has already been compiled. If I am at the UNIX command
prompt I can run the program by typing in "~/runsgood.exe". The
program then prompts me for an input file for it to use. It says:
ENTER INPUT FILE NAME WITHOUT .in EXTENSION. and when I obey I get
nothing at the prompt except there will be
a new file in my current directory with the same root as I gave it but
a .out extension. I can also run the program by preparing a file
containing the root name including the path: ~/runsgood.exe<point. The
file "point" is a single
line: ~/directory/root . When I run the program this way I see the
prompt but the program gets its answer from the file "point". The
problem is it doesn't do this from the sys command. Here is the script
I use to try it:
#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qwstandard -no_xhtml);
use diagnostics;
my $co = new CGI;
my $newID=cookie('newID');
system "sed s/old/$newID/ point_old >point.$newID";
system "~/runsgood.exe<point.$newID";
print $co->redirect('~/cgi-bin/done.cgi');
and when I run the script here's what appears in a browser window:
ENTER INPUT FILE NAME WITHOUT .in EXTENSION
Status: 302 Moved
Location: ~/cgi-bin/done.cgi
The prompt from runsgood.exe appears, just as it does when I run it
interactively. The program does its job and the output does appear in
my directory as it should, but it cannot get to the last line for some
reason. Does anybody know how to stop this? I was hoping that I would
get the prompt to disappear because I had no header in the script, and
I hoped that it would move on to the script 'done.cgi' but no such
luck. I need to find a way to get to that last script. Thanks for any
help.
mike