Python子流程不与OpenVPN合作

发布于 2025-02-09 02:25:02 字数 519 浏览 1 评论 0原文

我正在尝试使用子过程连接到OpenVPN。当我将其直接输入终端时,该命令正常工作,但是由于某种原因,它在子过程命令中不起作用。

代码:

import subprocess

# use shell command to connect openvpn
r = subprocess.Popen(['openvpn', '--config', 'config.ovpn'], shell=True)

它返回OpenVPN的通用响应,例如:

General Options:
--config file   : Read configuration options from file.
--help          : Show options.
--version       : Show copyright and version information.
... 100 more lines of help info

它似乎没有添加配置选项。

知道为什么吗?

I'm trying to use a subprocess to connect to openvpn. The command works fine when I enter it directly into the terminal, however, it does not work inside a subprocess command for some reason.

Code:

import subprocess

# use shell command to connect openvpn
r = subprocess.Popen(['openvpn', '--config', 'config.ovpn'], shell=True)

Which returns a generic response from openvpn like:

General Options:
--config file   : Read configuration options from file.
--help          : Show options.
--version       : Show copyright and version information.
... 100 more lines of help info

It doesn't seem to be adding the config options.

Any idea why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文