2016-07-20 7 views
0

目的:実行時間が長すぎる場合、Revit(または任意の実行可能ファイル)とタイムアウトを実行するPerlスクリプト。私はRevitを実行することができますが、タイムアウトを追加したり、引数$を$ out $ errで実行する他のバージョンを使用することはできません。IPC :: Runタイムアウトが機能しない

Windows環境。

以下は、動作する1つの「実行」と、まったく動作しない他のものの結果です。特に、タイムアウトを指定できる箇所があります。

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: 
run @cmd1; 

#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 
run \@cmd1; 

#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"; 

答えて

1

あなたは

"C:\Program Files\Autodesk\Revit 2016\Revit.exe" 

という名前のファイルを実行するためにそれを教えてくれますが、ファイルが

C:\Program Files\Autodesk\Revit 2016\Revit.exe 

01と

my @cmd1 = "\"$revitPath\""; 
run \@cmd1, ... 

を交換して命名されました

my @cmd1 = $revitPath; 
run \@cmd1, ... 

または

run [ $revitPath ], ... 
+0

ありがとうございました!完全に働いた。 (明らかにperlのnewb)私は私のdunceの帽子で角で終わるでしょう。 – MarshAPI

関連する問題