Explora mis guías, scripts y procedimientos para instalar, utilizar y probar diversas herramientas, desde configuraciones de Docker hasta entornos de Python. Esto incluye instalaciones a través de gestores de paquetes como Pacman y apt, así como trabajar con contenedores y scripts bash.
Para recibir archivos con el servidor Python desde otra máquina, ejecute un comando curl como este: curl -T file.txt http://Ourserver:8000 after running the getpython script.
getpython2
Serving HTTP on 0.0.0.0 port 8000 ...
---------------------------------------------------------------
To extract the file to our machine:
curl -T file.txt http://ServerIP:8000.
#!/usr/bin/python2
print("to receive files with Python 2, from the other machine, do a curl like this:")
print("curl -T secrec http://192.168.88.19:8000")
print("")
import SimpleHTTPServer
import BaseHTTPServer
class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_PUT(self):
print self.headers
length = int(self.headers['Content-Length'])
path = self.translate_path(self.path)
with open(path, 'wb') as dst:
dst.write(self.rfile.read(length))
if __name__ == '__main__':
BaseHTTPServer.test(HandlerClass=SputHTTPRequestHandler)
#!/usr/bin/python3
print("to receive files with Python 2, from the other machine, do a curl like this:")
print("curl -T file.txt http://192.168.88.19:8000")
print("")
from http.server import SimpleHTTPRequestHandler, HTTPServer
class SputHTTPRequestHandler(SimpleHTTPRequestHandler):
def do_PUT(self):
print(self.headers)
length = int(self.headers['Content-Length'])
path = self.translate_path(self.path)
with open(path, 'wb') as dst:
dst.write(self.rfile.read(length))
if __name__ == '__main__':
HTTPServer(('', 8000), SputHTTPRequestHandler).serve_forever()
❯ getpython
to receive files with Python 2, from the other machine, do a curl like this:
curl -T file.txt http://192.168.88.19:8000
Host: 192.168.88.19:8000
User-Agent: curl/8.4.0
Accept: */*
Content-Length: 4
Este es el ejemplo de cuando has recibido un archivo de otro servidor con curl.
#!/usr/bin/python3
from os import dup2
from subprocess import run
import socket
# Function to print with color
def print_color(message, color_code):
print("\033[" + str(color_code) + "m" + message + "\033[0m")
# Message
print_color("Run nc nvlp 1234 on the other machine", 95)
# Ask for the IP
ip = input("\033[93mEnter the IP address: \033[0m")
# Ask for the port
default_port = 1234
port_input = input("\033[93mDefault port 1234? [c] to change: \033[0m")
if port_input.lower() == 'c':
port = int(input("\033[93mEnter the port: \033[0m"))
else:
port = default_port
# Confirm before executing
execute = input(f"\033[92mExecute con...