如何在后台连接到 ssh 服务



所以我想通过这个命令连接到servo

os.system("ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -R test:80:127.0.0.1:80 serveo.net > data.txt 2> /dev/null &")

现在,它按照我想要的方式工作,没有任何输出,我可以保留程序的其余部分,但是由于"/dev/null"部分,此命令仅适用于 linux,我也需要它在 Windows 上运行。Windows没有"/dev/null"文件夹,我可以将输出扔到其中。

那么有没有替代品呢?它必须与os.system一起使用。

尝试将 2>/dev/null & 替换为 > NUL 2>&1

来源:https://superuser.com/questions/777198/equivalent-of-foo-dev-null-in-windows-shell

最新更新