Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Connects to, obtains your external IP address and uploads a text file containg the IP to a chosen FTP server. Requires Python to run.
#! /usr/bin/env python
import httplib
import sys
import os
import ftplib
# File IP will be output to
# Replace server, user, and password with your login information
server = ""
user = "username"
password = "password"
conn = httplib.HTTPConnection("")
response = conn.getresponse()
data =
filename = str(os.path.abspath(os.path.dirname(sys.argv[0])) + "\\"+file) #Create file
FILE = open(filename,"w") #Open file ready for writing
FILE.writelines(data) #Write 'data' to file
FILE.close() #Close file
s = ftplib.FTP(server,user,password) #Connect
f = open(file,'rb') #File to send
s.storbinary('STOR '+file, f) #Send the file
f.close() #Close file and FTP
s.quit() #Quit FTP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.