python script to move files from open suse linux to windows 7
im a real newbie in linux and python. Learning stage. i want to create a python script that will move/push files from my linux pc to windows 7 pc. i will place that script in cron.hourly. how do i do that? i created a script to move files within linux pc's and it worked. but im having a tough time to create a script to move from linux to windows. can anyone please help? below is my script to move files
from linux to linux :
filePath = "/usr/local/testlogs/parse/*.*" #path of slave tester
serverPath = "/usr/local/testlogs/DB_parse" #path of master tester
files = glob.glob(filePath)
for f in files :
os.system("scp "+f+" firstname.lastname@example.org:"+serverPath)
time.sleep(1) #delay 1 sec before file gets deleted one by one.
os.remove(f) #copy and delete files to not save up space
print "parse directory is missing!!"
this script uses scp to copy files, therefore you need to install scp on your windows (something like this: http://www.techrepublic.com/blog/itd...-freesshd/3506, or cygwin's sshd)
Thanks! now i can scp from my linux pc to my windows pc. but now im facing another problem whereby, whenever i issue below command :
scp filename.txt email@example.com:/C:\...arathan.rajalingam\Desktop
it asks for password. when i key in my password and it says that that permission denied. any idea why?
It depends on several things. For example the users on linux and windows are different (probably), you need to use the user/password of the target system.
The user you entered has really no right to write into that directory. Probably you can check the log file of the sshd (which one have you installed?)
Do not use \ on linux, if you want to enter windows-like path, use double backslashes: c:\\something\\dir\\Desktop. Also use ' to avoid mishandling of your path:
scp filename.txt 'barathan.rajalingam@host:c:\\users\\barathan.rajalingam\\Desktop'
You can also configure passwordless login, just google "passwordless ssh login windows" and follow the steps.
|All times are GMT -5. The time now is 05:20 PM.|