Reputation: 522
I am trying to copy all the files from a folder to another in Linux. I am using Python from windows machine and connecting it to Linux. The code i wrote is below.
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 )
I am getting an error like this:
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/*.*'
Any idea what i am doing wrong here?
Upvotes: 0
Views: 116
Reputation: 2313
it doesnt work since you do os.listdir on your own machine (windows) and you put a linux path
i am not sure witch library you are using to connect to the linux machine but if the run method works you can do
run('cp /home/ndsuser/enc/data/dbSchema_1/catalogue_24802/* /usr/rosh/ENC_Analysis/')
Upvotes: 2