如何使用python挂载网络目录? [英] How to mount a network directory using python?

查看:277
本文介绍了如何使用python挂载网络目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Linux机器上使用python在网络机器数据"上安装目录"dir"

I need to mount a directory "dir" on a network machine "data" using python on a linux machine

我知道我可以通过命令行发送命令:

I know that I can send the command via command line:

mkdir ~/mnt/data_dir
mount -t data:/dir/ ~/mnt/data_dir

但是我该如何从python脚本发送这些命令?

but how would I send those commands from a python script?

推荐答案

这是一种方法:

import os

os.cmd ("mkdir ~/mnt/data_dir mount -t data:/dir/ /mnt/data_dir")

如果要在脚本中读取命令的输出,也可以使用"popen".

You can also use "popen" if you want to read the output of the command in your script.

HIH

...里奇

这篇关于如何使用python挂载网络目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆