NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Mar 14, 2010 2:35 pm Post subject: [Linux/Python] Copy files from remote shell terminal? |
|
|
Heya.
While messing around on uselesspython.com, I found a source code which allows you to execute bash commands from a remote computer, but was wondering how I would be able to copy the files from the remote computer, to the local computer.
The codes are:
Client (On local computer)
| Code: | #!/usr/bin/env python
import socket
IP = raw_input('IP: ')
PORT = input('PORT: ')
while 1:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((IP,PORT))
send = raw_input('Send: ')
sock.send(send)
print sock.recv(2048)
sock.close() |
Server (On remote computer)
| Code: | #!/usr/bin/env python
import socket
from subprocess import *
IP = '0.0.0.0'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((IP, 1234))
sock.listen(5)
while True:
channel, details = sock.accept()
command = channel.recv(2048)
#log = open('log.log', 'a')
#log.write(str(details))
#log.write('\n')
try:
echo = Popen(command, shell=True, stdout=PIPE).stdout.read()
channel.send(echo)
#log.write(echo)
except:
channel.send('Eh?')
#log.close()
channel.close() |
Summarized:
I'm on my laptopt downstairs while my desktop pc is running upstairs.
I connect with my laptop using the client code, while the server code is running on the desktop.
How would I copy files from desktop pc while being on my laptop?
|
|