2016-07-20 65 views
0

目標:運行Revit(或任何可執行文件)的Perl腳本以及運行時間過長的超時。我有它來運行Revit,但似乎無法添加超時或使用其他版本的運行參數$ in $ out $ errIPC ::運行超時不起作用

Windows環境。

下面是一個「運行」的作品和其他人根本不工作的結果,特別是我希望在哪裏可以指定超時。

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 

更換

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

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

run [ $revitPath ], ... 
+0

太謝謝你了!完全合作。 (顯然是perl newb)我會在角落裏戴上我的帽子。 – MarshAPI