我正在嘗試使用系統命令從遠程服務器調用帶有標誌的perl腳本。當我發出命令時,由於某些奇怪的原因,我的最後兩個標誌被忽略。有些人可以給我提供一些指導。提前致謝!!!!perl中的系統()
#!/usr/bin/perl
print "Webserver?\n";
my $webserver = <STDIN>;
print "PORT?\n";
my $port = <STDIN>;
system("ssh -t <HOST> \"sudo su - root -c '/WebAppSA/apache/V2.2/install_apache/webmaster.pl -C -name:$webserver -port:$port - cert:cert.com'\"");
錯誤信息 無法確定網絡服務器的唯一端口。 請檢查您的設置,然後重試。正在中止... -bash:第1行:-port:8284:command not found -bash:line 2:-cert:cert.com:command not found
我知道這可能是演示代碼,但請注意 - 您將未經驗證的,未轉義的用戶提供的輸入傳遞到遠程計算機上的根shell。 (你自己的子shell也有風險。)請看列表或間接對象調用'system()'並列出[根據文檔](http://perldoc.perl.org/functions/system.html )。或者,'quotemeta()'或'\ Q'比裸插值要好。 – pilcrow 2012-03-28 13:35:42
[Perl腳本中的XML編輯]的可能重複(http://stackoverflow.com/questions/9877485/xml-editing-inside-a-perl-script) – 2012-03-28 18:47:22
@per docs:'quotemeta'用於常規表達式,而不是殼牌報價。 – salva 2012-03-29 11:02:14