【问题标题】:how to invoke sshfs within python script?如何在 python 脚本中调用 sshfs?
【发布时间】:2010-01-08 12:03:39
【问题描述】:

我想使用 sshfs 挂载一个远程目录。 sshfs 从终端工作正常。 但是如何从 python 脚本中调用它呢?

我尝试了类似的方法 - 但根本没有用。

import os

cmd = "/usr/bin/sshfs giis@giis.co.in:/home/giis /mnt" 
os.system(cmd)

【问题讨论】:

  • 结果如何?如果您告诉我们出了什么问题,我们可以为您提供更好的帮助。
  • 这里是输出:python: can't open file 'sshfs': [Errno 2] No such file or directory
  • 路径是否正确?尝试which sshfs 在 shell 中查找。
  • sshfs 在正确的路径中。手动调用 sshfs 将远程目录安装在本地安装点下。但不要使用 python 脚本...
  • 是的..用root权限安装了sshfs并更改为root并执行上述脚本有效:) ..谢谢大家

标签: python sshfs


【解决方案1】:

首先,您应该确保您的 sshfs 命令使用 shell 可以正常工作。然后去here看很多使用Python的subprocess模块​​调用你的sshfs命令的例子

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 2016-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多