python指定另一服务器路径,如何从python中指定的路径获取文件?

这段代码展示了一个Python脚本,旨在从Windows通过PyCharm连接到Linux服务器,然后在服务器上切换到特定目录并解压缩文件。脚本使用Fabric库进行远程操作,包括列出文件、删除现有内容、复制文件和解压缩文件。问题在于脚本尝试在Windows环境中执行Linux特定的路径操作,导致错误。
摘要由CSDN通过智能技术生成

我正在将一组zli文件从一个文件夹复制到另一个文件夹。现在我需要解压缩该文件夹中的每个文件。我使用Pycharm从Windows运行python,文件夹在Linux服务器上。如何才能到达当前文件夹并解压缩每个文件?在from __future__ import with_statement

from fabric.api import *

import ConfigParser, paramiko, shutil, os, glob, zlib

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')

run('rm -rf /usr/rosh/ENC_Analysis/*')

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

count = run('ls -l /usr/rosh/ENC_Analysis/ | wc -l')

os.chdir('/usr/rosh/ENC_Analysis/')

for file in os.listdir('/usr/rosh/ENC_Analysis/'):

print file

如果我运行这个代码,我会得到如下问题。在

^{pr2}$

我知道这个问题是因为系统无法在Windows机器中找到路径。如何从Windows机器访问Linux服务器中的路径?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值