2013-04-23 131 views
1

我可以在Perl中運行一些Shell Linux命令(例如創建文件夾)。但我不能執行後面的命令:在Perl中運行Shell命令

echo 'mypassword' | gpg --passphrase-fd 0 --output outfile --decrypt inputfile 

我在.sh文件中添加此命令,並可以在Shell中執行正常。但是當我調用.sh文件時,Perl無法運行它。我用open3,system,open命令來運行。我可以運行其他.sh文件,但不能用於此命令。

你能幫助我嗎?

回答

0

嘗試使用反引號/反引號,似乎很好地工作:

#!/usr/bin/perl 
use strict; 

`echo 'mypassword' | gpg --passphrase-fd 0 --output outfile --decrypt inputfile` 

附:我最好使用一些類似GPG的cpan模塊。