B
bbiker
I have written a program that uses a system() call.
I can only run the program once in a dos window.
Each run must be made in a newly opened dos window.
I conducted the following tests to determine if the problem resides in
the program (bigdeal.exe) invoked by the system() or in Ruby.
I wrote two test programs that uses bigdeal.exe in the system() call,
one in ruby and one in perl.
The results are shown below. I believe that the results clearly show
the problem resides in Ruby. It appears that it is NOT a bigdeal.exe or
a DOS problem since the perl program succeeds every time. Perl's
system() does not have this problem.
############## first run
C:\Projects\Ruby\DDA\lib>perl bigdeal.pl
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: "0"
############## second run
Crojects\Ruby\DDA\lib>perl bigdeal.pl
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: "0"
NOTE I can run the bigdeal.pl as often as I want in the same DOS window
#########################################################################
# in a new window
#########################################################################
C:\Projects\Ruby\DDA\lib>bigdeal.rb
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: ""
As shown above the system() call to bigdeal.exe succeeded and the
output
file was produced.
##########################################################################
Any subsequent attempts to issue the command in the same window, the
system()
call fails in the following manner:
system() freezes after bigdeal prints its prompts and processes the
keyboard inputs...
the system() call does not return anything in bigdeal.rb and the output
file is not created.
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
NEED TO KILL THE DOS WINDOW at this point
############################################################################
NOTE The same behavior occurs if I attempt to run bigdeal.rb in the
same window that bigdeal.pl ran.
NOTE I can run bigdeal.pl in the same window I ran bigdeal.rb.
__RUBY_CODE__
#!c:/ruby/bin/ruby -w
# generate 36 random deals
retval = system("bigdeal -n 36 -p rb_deals")
print "system call returned: \"#{retval}\"\n"
__PERL_CODE__
#! perl
use warnings;
use strict;
# generate 36 random deals
my $retval = system ("bigdeal -n 36 -p df_deals");
print "system call returned: \"$retval\"\n";
Hopefully someone more knowledgeable and capable than I will confirm
the problem and resolved it.
bigdeal.exe can be obtained from http://www.xs4all.nl/~sater/
the very first time you run bigdeal.exe, it will ask several questions.
I requested the output file to be in CSV format.
I can only run the program once in a dos window.
Each run must be made in a newly opened dos window.
I conducted the following tests to determine if the problem resides in
the program (bigdeal.exe) invoked by the system() or in Ruby.
I wrote two test programs that uses bigdeal.exe in the system() call,
one in ruby and one in perl.
The results are shown below. I believe that the results clearly show
the problem resides in Ruby. It appears that it is NOT a bigdeal.exe or
a DOS problem since the perl program succeeds every time. Perl's
system() does not have this problem.
############## first run
C:\Projects\Ruby\DDA\lib>perl bigdeal.pl
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: "0"
############## second run
Crojects\Ruby\DDA\lib>perl bigdeal.pl
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: "0"
NOTE I can run the bigdeal.pl as often as I want in the same DOS window
#########################################################################
# in a new window
#########################################################################
C:\Projects\Ruby\DDA\lib>bigdeal.rb
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
system call returned: ""
As shown above the system() call to bigdeal.exe succeeded and the
output
file was produced.
##########################################################################
Any subsequent attempts to issue the command in the same window, the
system()
call fails in the following manner:
system() freezes after bigdeal prints its prompts and processes the
keyboard inputs...
the system() call does not return anything in bigdeal.rb and the output
file is not created.
Big Deal version 1.1
Type random characters until you are told to stop
That is enough
NEED TO KILL THE DOS WINDOW at this point
############################################################################
NOTE The same behavior occurs if I attempt to run bigdeal.rb in the
same window that bigdeal.pl ran.
NOTE I can run bigdeal.pl in the same window I ran bigdeal.rb.
__RUBY_CODE__
#!c:/ruby/bin/ruby -w
# generate 36 random deals
retval = system("bigdeal -n 36 -p rb_deals")
print "system call returned: \"#{retval}\"\n"
__PERL_CODE__
#! perl
use warnings;
use strict;
# generate 36 random deals
my $retval = system ("bigdeal -n 36 -p df_deals");
print "system call returned: \"$retval\"\n";
Hopefully someone more knowledgeable and capable than I will confirm
the problem and resolved it.
bigdeal.exe can be obtained from http://www.xs4all.nl/~sater/
the very first time you run bigdeal.exe, it will ask several questions.
I requested the output file to be in CSV format.