Goal: Perl script that runs Revit (or any executable) and timesout if runs too long. I've got it to run Revit but can't seem to add a timeout or use the other versions of run with arguments $in $out $err
Below is the one "run" that works and the results of others that don't work at all, especially the one I'd like where I can specify a timeout.
use IPC::Run qw( run timeout );
my $revitPath = "C:\\Program Files\\Autodesk\\Revit 2016\\Revit.exe";
#I think I need quotes because there are spaces in the line
my $revitExe = "\"$revitPath\"";
my @cmd1 = "\"$revitPath\"";
#don't think I need any arguments, just want to start it for now and time out.
my $in = "";
my ($out, $err);
#Here We're Happy, runs Revit:
#All the following: Not Happy:
#This one just seems to do nothing, no complaints, just does nothing
#-----> This is the main goal. I want to time out Revit if it runs too long.
run @cmd1, timeout(40000) or die "cat: $?";
#This one says "file not found: "C:\Program Files\Autodesk\Revit 2016\Revit.exe" at line 16
#This one says
#Unexpected SCALAR(0x1d21adc) in harness() parameter 3 at example.pl line 21
#Unexpected SCALAR(0x1d21acc) in harness() parameter 4 at example.pl line 21
run @cmd1, \$in, \$out, \$err;
#This one says "file not found: "C:\Program Files\Autodesk\Revit 2016\Revit.exe" at line 24
run @cmd1, $in, $out, $err;
print "out: $out\n";
print "err: $err\n";
You tell it to execute a file named
"C:\Program Files\Autodesk\Revit 2016\Revit.exe"
but the file is named
C:\Program Files\Autodesk\Revit 2016\Revit.exe
my @cmd1 = "\"$revitPath\""; run \@cmd1, ...
my @cmd1 = $revitPath; run \@cmd1, ...
run [ $revitPath ], ...