Hacker Monthly has a special, free, edition about Startup Marketing.
I trully recomend it for all entrepreneurs.
./M6
Automatic FTP
I currently need to upload of some text files via FTP, but since some files are big, over 5Gb, I get a lot timeouts, which stops me from using the FTP mput command.
So, I've developed a small Python script to automate this task and avoid the timeouts.
It has the following features:
After setting things up for one's needs, it's quite easy to use.
To transfer all .txt files starting with "A" from the default local directory, just:
To transfer all .xml files from a specific directory "Z:\test", just:
If one needs to adapt this to either get file, i.e. download, or to support binary file, just check the Python ftplib documentation, it's quite easy.
./M6
So, I've developed a small Python script to automate this task and avoid the timeouts.
It has the following features:
- can be scheduled;
- accepts file masks;
- assumes a default local directory where the files to be uploaded are located;
- supports text files only;
- opens the connection for each file transfer in order to avoid timeout problems;
# -*- coding: iso-8859-15 -*-
'''
Automatic FTP
'''
import sys
import string
import ftplib
import os
import glob
import datetime
# Server name or IP address
__SERVER = "server.com"
# FTP username
__USER = "username"
# FTP password
__PASSWORD = "password"
# Default local directory were files are located to be uploaded
__DEFAULT_LOCATION = "C:\\ftp\\upload"
#
# Shows the time difference.
#
def showTimeDifference(init):
td = datetime.datetime.now()-init
print "in",td.seconds,"seconds (",td.seconds/60," minutes )."
#
# Transfers the files
#
def transferFile(ftpFile):
ftpInit = datetime.datetime.now()
file = os.path.basename(ftpFile)
print "\tTransfering:",file,
ftp = ftplib.FTP(__SERVER)
ftp.login(__USER, __PASSWORD)
ftp.storlines("STOR " + str(file).upper(), open(ftpFile))
ftp.close()
showTimeDifference(ftpInit)
print ""
#
# Get the files to transfer
#
def getTransferFiles(location, mask):
result = []
for file in glob.glob1(location, mask):
result.append(os.path.join(location, file))
return result
#
# Main
#
def main(args):
fileMask = ""
fileLocation = __DEFAULT_LOCATION
if len(args) == 2:
fileMask = sys.argv[1]
elif len(args) == 3:
fileMask = args[1]
fileLocation = args[2]
else:
print "autoFTP filemask [location]"
sys.exit(0)
print "Transfer files from",fileLocation,"to", __SERVER,"..."
ftpInit = datetime.datetime.now()
for file in getTransferFiles(fileLocation, fileMask):
transferFile(file)
print "Transfer competed",
showTimeDifference(ftpInit)
#
# Main
#
main(sys.argv)
After setting things up for one's needs, it's quite easy to use.
To transfer all .txt files starting with "A" from the default local directory, just:
python autoFTP A*.txt
To transfer all .xml files from a specific directory "Z:\test", just:
python autoFTP *.xml Z:\test
If one needs to adapt this to either get file, i.e. download, or to support binary file, just check the Python ftplib documentation, it's quite easy.
./M6
ZX Spectrum Relaunch!
I belong to the ZX Spectrum generation.
I grew up with a rubber keyboard on the tip of my fingers and I've spent too much hours in a row in front of a black and white small television...
This revolutionary machine is almost 30 years old and to celebrate that there will be a brand new ZX Spectrum 48K, with the same old games and some innovations...
48K rocks! :)
./M6
I grew up with a rubber keyboard on the tip of my fingers and I've spent too much hours in a row in front of a black and white small television...
This revolutionary machine is almost 30 years old and to celebrate that there will be a brand new ZX Spectrum 48K, with the same old games and some innovations...
48K rocks! :)
./M6
The Math Behind Consulting Companies
An entrepreur friend pointed me to this very interesting post about the math behind consulting companies.
Here it is: The unfortunate math behind consulting companies.
./M6
Here it is: The unfortunate math behind consulting companies.
./M6
Subscribe to:
Posts (Atom)