?
Solved

How to copy files from windows machine to linux server in Python?

Posted on 2011-03-16
3
Medium Priority
?
2,305 Views
Last Modified: 2012-05-11
How to copy files from windows machine to linux server in Python?


0
Comment
Question by:milindbansode
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Assisted Solution

by:vks_vicky
vks_vicky earned 800 total points
ID: 35146663
1. First mount your Windows server on linux (Samba share)

2. And then implement a normal copy program in Python to copy.
0
 
LVL 8

Accepted Solution

by:
LunarNRG earned 1200 total points
ID: 35148929
You can use ssh/scp to copy files from windows to a linux server. There are several ssh implementations in python, some rather old and possibly unmaintained ... for example, paramiko[1], pyssh[2], and twisted-conch[3]. But you can also just wrap a system call to your favorite windows scp client[4]. Something like (completely untested),

#!/usr/bin/env python
from subprocess import Popen, PIPE, STDOUT

# you must pre-configure putty/pscp to use pub key auth
def remote_copy(server, user, src, dst):
    p = Popen(
        'pscp.exe -batch %(src)s %(user)s@%(server)s:%(dst)s' % locals(), 
        shell=True, stdout=PIPE, stderr=STDOUT
    )
    all_output, null = p.communicate()
    return all_output

Open in new window


[1] http://www.lag.net/paramiko/
[2] http://pyssh.sourceforge.net/
[3] http://twistedmatrix.com/documents/current/conch/howto/conch_client.html
[4] http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html#pscp
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question