gpt4 book ai didi

linux - 在 Perl 中运行 Shell 命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:36:56 24 4
gpt4 key购买 nike

我可以在 Perl 中运行一些 Shell Linux 命令(例如创建文件夹)。但我无法执行以下命令:

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

我在 .sh 文件中添加了这个命令,并且可以在 Shell 中正常执行。但是当我调用 .sh 文件时,Perl 无法运行它。我使用了open3systemopen命令来运行。我可以运行其他 .sh 文件,但不能运行此命令。

你能帮帮我吗?

最佳答案

尝试使用反引号/反引号,似乎工作正常:

#!/usr/bin/perl
use strict;

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

附言我最好使用一些 cpan 模块,例如 GPG .

关于linux - 在 Perl 中运行 Shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16164179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com