Cool Engineering

Info on some cool engineering projects

Friday, September 07, 2007

DOS isn't completely useless

This is somewhat in response to a Linux supporter friend of mine that said a fresh install of Windows was "completely useless". Having used Linux off and on - the issue here is getting a fresh install of Linux - fairly simple with a fresh install of Ubuntu (though the wireless card still doesn't work which he admitted to being a Linux-centric issue), but it used to be an enormous pain with older versions - I wasted several weekends getting my old Linux box setup.
Back to Windows then. A couple of years ago I got into writing DOS batch files - mainly for doing backups and the like - and when coupled with something like WinRAR they can provide automated, date/time stamped, compressed backup. Since hard drive space isn't a huge issue at work I have set scripts to make a copy of all my important folders date and time stamped. We do use code versioning, but on a couple of occasions doing this has really got me out of a mess - forgot to check something in, or a PDF or Word doc which doesn't respond well to binary diffs. I will post that code soon, but first I wanted to show a really simple FTP uploader. It requires nothing more than a standard Windows build. It's not very secure (passwords are stored in plain text - though in FTP they are transmitted in plain text anyway). It is very functional though as when created as an icon on the Windows desktop - when a item is dragged and dropped onto this icon it will initiate the script and automatically upload the file.
Below is the script:

@echo off
> c:\script.txt echo open ftp.yourlocation.com
>> c:\script.txt echo username
>> c:\script.txt echo password
>> c:\script.txt echo cd Uploads
>> c:\script.txt echo send %1
>> c:\script.txt echo bye
ftp -s:c:\script.txt
del c:\script.txt

The script creates another file to execute (script.txt) which is deleted when the script terminates. You replace the username and password for the ftp username and password. "cd Uploads" refers to the destination directory - eg. cd Upload/Robert/pictures. "%1" refers to the command line argument supplied to the script from the drag and drop function.
Very simple and functional. I personally use this for uploading sermons from church onto the Church website where some cleverly crafted PHP interprets the sermon names and displays them to the screen - all without me having to manually FTP in - marvellous.

0 Comments:

Post a Comment

<< Home