使用shuti将文件从一个文件夹复制到另一个文件夹

2024-05-15 13:39:50 发布

您现在位置:Python中文网/ 问答频道 /正文

在Linux中,我正在尝试将所有文件从一个文件夹复制到另一个文件夹。我正在从windows机器上使用Python并将其连接到Linux。我写的代码如下。你知道吗

def get_Connection():
config = ConfigParser.RawConfigParser()
config.read('config.cfg')
env.user = config.get('UK_CDN','db.user_name' )
env.password = config.get('UK_CDN','db.password' )
host = config.get('UK_CDN','db.ip' )

with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True, host_string=host):
    paramiko.util.log_to_file('ENC_Analysis.log')
    files = run('ls -ltr /home/ndsuser/enc/data/dbSchema_1/catalogue_24802')
    src = os.listdir('/home/ndsuser/enc/data/dbSchema_1/catalogue_24802/')
    dst = os.listdir('/usr/rosh/ENC_Analysis/')
    for files in src:
        shutil.copytree(src,dst )

我得到了这样一个错误:

Traceback (most recent call last):
File "C:/Work/Scripts/VOD/ENC.py", line 27, in <module>
get_Connection()
File "C:/Work/Scripts/VOD/ENC.py", line 17, in get_Connection
src = os.listdir('/home/ndsuser/enc/data/dbSchema_1/catalogue_24802/')
WindowsError: [Error 3] The system cannot find the path specified:  '/home/ndsuser/enc/data/dbSchema_1/catalogue_24802/*.*'

知道我做错了什么吗?你知道吗


Tags: srcconfighosthomedbdatagetcdn
1条回答
网友
1楼 · 发布于 2024-05-15 13:39:50

既然你这么做了,它就不起作用了操作系统列表目录在你自己的机器(windows)上,你把一个linux路径

我不确定你用witch库连接到linux机器,但是如果run方法有效,你可以这样做

run('cp /home/ndsuser/enc/data/dbSchema_1/catalogue_24802/* /usr/rosh/ENC_Analysis/')

相关问题 更多 >