-1

We have a framework used to validate few test cases and results will be stored in local machine containing multiple text and images.

Need to move these files from our local host to server.

I have the sever IP address, username and password.

So using Python I need to move these files or copy it to server

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Sriharsha G
  • 17
  • 1
  • 2
  • Which protocol do you need to use? ssh? http? ftp? – jhoepken Jun 26 '15 at 09:05
  • How should the files be transfered? (S)FTP, SCP, SMB, NFS, HTTP(S), ...? – albert Jun 26 '15 at 09:06
  • what OSs are you using, which server services are running on the server (for example ssh or ftp) that you could use to upload the files? did you already search the web for "how to transfer files between computers" or the like? what did you try and what did you investigate so far? basically, you first decide how to transfer them, and then you decide how to do that from python. – hoijui Jun 26 '15 at 09:07
  • I am using Linux(both host and sever) so we can use ftp or ssh or just a cp commands – Sriharsha G Jun 26 '15 at 09:08
  • possible duplicate of [How to scp in python?](http://stackoverflow.com/questions/250283/how-to-scp-in-python) – jhoepken Jun 26 '15 at 09:11
  • Why python at all? Just `scp username@server:/path/to/store` – Noufal Ibrahim Jun 26 '15 at 09:12

3 Answers3

2

If you are going for ssh, you'll have to use scp and there is a dedicated Python package for that: Paramiko. See this post on stackoverflow.

import paramiko

def createSSHClient(server, port, user, password):
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(server, port, user, password)
    return client

ssh = createSSHClient(server, port, user, password)
scp = SCPClient(ssh.get_transport())
scp.put([file1,file2],remotePath)

Of course, you have to specify the various variables according to their name. The scp.put function takes a list of local files and a destination path on the remote system as arguments.

Community
  • 1
  • 1
jhoepken
  • 1,842
  • 3
  • 17
  • 24
0

This is not really a Python problem: You say you have a username and a password to the server, but that doesn't tell us the least in which way you can access that server. Do you have SSH access? Then use scp as a command-line program or one of the numerous Python modules that make that possible.

The same goes for protocols like FTP, WebDAV, cifs/smb, NFS, ... It all depends on what ways you have to access/modify/create files on the server. Hence, this answer is all I can give you to your extremely inaccurate question.

Milan
  • 1,743
  • 2
  • 13
  • 36
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
0

used SCP to do the transfer ssh -i ~/.ssh/id_rsa intel@10.223.98.165 "mkdir < Folder created >"

scp -i ~/.ssh/id_rsa < source >*.txt < destination > using os.system() Thanks for helping

Sriharsha G
  • 17
  • 1
  • 2