LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 12-19-2012, 01:39 AM   #1
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 15

Rep: Reputation: Disabled
python script to move files from open suse linux to windows 7


hello All!

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 :

import os
import time
import glob

filePath = "/usr/local/testlogs/parse/*.*" #path of slave tester
serverPath = "/usr/local/testlogs/DB_parse" #path of master tester

try :
files = glob.glob(filePath)
for f in files :
os.system("scp "+f+" root@192.168.10.1:"+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

except OSError:
print "parse directory is missing!!"
 
Old 12-19-2012, 03:12 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,527

Rep: Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228
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)
 
Old 12-19-2012, 04:14 AM   #3
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
hi There!
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 barathan.rajalingam@10.34.52.58:/C:\...arathan.rajalingam\Desktop

it asks for password. when i key in my password and it says that that permission denied. any idea why?
 
Old 12-19-2012, 04:52 AM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,527

Rep: Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Shell Script to rename and move files to a different folder in Windows Simon1984 Linux - Newbie 10 05-18-2012 10:50 AM
How to close open ports using a python script or a shell script in python ?? apanimesh061 Programming 3 11-20-2011 12:31 AM
how to move files from windows server to linux server by script topsy999 Linux - Newbie 2 01-15-2009 12:40 PM
How to Move Files from Windows to Linux b18b Linux - Networking 8 03-20-2006 06:03 PM
open windows files in SuSE Linux professional 9.1 SyncMaster Linux - Newbie 3 05-20-2005 09:00 AM


All times are GMT -5. The time now is 07:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration