嗨,我正在尝试将文件夹从源复制到目标,但出现以下错误:

cp: cannot create directory ‘/home/Workspace/Release/addons/’: No such file or directory

我输入了以下命令:
cp -R /home/Workspace/Dev/user1/addons/account /home/Workspace/Release/addons/

我在不同的文件夹中尝试了相同的命令,但效果很好。
cp -R /home/Desktop/file_transfer/f1/ff1 /home/Desktop/file_transfer/f2/

编辑:Q2。当我在以下代码中传递命令时:
import os
import re
dest = "/home/Workspace/Release/addons/"
root = "/home/Workspace/Dev/user1/addons/"
f = open("/home/appslab/Desktop/main/FTP/release.conf.text", 'r')
for line in f:
    filepath = root+line
    command = "cp -R "+str(filepath)+"\ "+str(dest)
    print(command)
    os.system(command)

我收到以下错误:
~/Desktop/FTP$ sudo python oswalk.py
cp -R /home/appslab/Workspace/PythonDevserver/appslab/addons/account
 /home/appslab/Workspace/PythonRelease/addons
cp: missing destination file operand after ‘/home/appslab/Workspace/PythonDevserver/appslab/addons/account’
Try 'cp --help' for more information.
sh: 2: /home/appslab/Workspace/PythonRelease/addons: Permission denied

我要传递给commandos.system()是因为dest显示在下一行中,谁能告诉我问题出在哪里?谢谢。
EDIT2:该目录的权限:
drwxrwxr-x 363 user1 user1  16384 Sep 16 21:57 addons

EDIT3:Fix for Q2:
command = `str("cp -R ")` + str(filepath)+"\ "+str(dest)

最佳答案

您收到permission denied错误。

使用以下命令更改插件目录的权限

sudo chmod -R 755 /home/Workspace/Release/addons/

关于linux - cp : cannot create directory : No such file or directory,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39847496/

10-12 04:17