【问题标题】:cp: cannot stat ‘/mnt/ask78b30/TEST_FILE’: Remote I/O errorcp: cannot stat ‘/mnt/ask78b30/TEST_FILE’: 远程 I/O 错误
【发布时间】:2016-12-24 12:49:53
【问题描述】:

我正在将文件复制到 nfs 挂载目录。当我手动运行以下命令时,文件已成功复制

sudo cp TEST_FILE /mnt/ask78b30

但是,当我在 python 脚本中使用相同的命令时,会出现以下错误,

运行 cmd = sudo cp TEST_FILE /mnt/ask78b30

cp: cannot stat ‘/mnt/ask78b30/TEST_FILE’: Remote I/O error

下面是代码:

    cmd = "sudo cp "+file_name_arg+" "+ mount_pt_arg

    print "cmd = ", cmd

    os.system(cmd)

注意:由于添加了特殊字符,以前的命令过去常常失败。我将 outty 更改为 UTF-8 并解决了 cp: cannot stat â/mnt/askdab3c/TEST_FILEâ: Remote I/O error

【问题讨论】:

    标签: python linux shell mount cp


    【解决方案1】:

    我会建议使用 pythons shutil 来复制文件而不是调用 cp

    from shutil import copyfile
    
    copyfile(src, dst)
    

    【讨论】:

    • 我之前尝试过建议的方法。这导致脚本终止文件“/home/root1/test-fifaa/test-common/tests/testautomation/Lib_Support_Functions.py”,第 154 行,Write_Test_File_To_Share shutil.copy2(file_name_arg, mount_pt_arg) 文件“/usr/lib/python2 .7/shutil.py”,第 130 行,在 copy2 中的 copyfile(src, dst) 文件“/usr/lib/python2.7/shutil.py”,第 83 行,在带有 open(dst, 'wb') 的 copyfile 中fdst:IOError:[Errno 121] 远程 I/O 错误:'/mnt/ask5f0f0/TEST_FILE'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 2022-01-06
    • 2017-09-08
    相关资源
    最近更新 更多