Darth.Vader
Darth.Vader

Reputation: 6301

python move files on remote host

I have a python script that needs to move a directory on a remote host from one location to another.

From a terminal, I can ssh into the remote host and then mv -r src dest will mv the relevant directory on that remote host.

> ssh USER@REMOTE
> mv -r SRC DEST

How can I do this through python?

Upvotes: 0

Views: 1247

Answers (1)

Linux Guide
Linux Guide

Reputation: 36

import paramiko
ssh = paramiko.SSHClient()
ssh.connect('REMOTE', username='USER', 
    password='PASSWORD')
stdin, stdout, stderr = \
ssh.exec_command("mv -r SRC DEST")

Upvotes: 2

Related Questions