|
Silly Software Company
-=oOo=- A poor man's way of doing things is still a way to get things done |
This document assumes you've created a web site on a personal computer, at home or so. Everything looks great, except that no-one will ever get to see it unless it gets on the internet. That is : you need to upload your web pages to a server, a computer that is permanently connected to the internet, and accessible for web browsers. Usually, your internet service provider (ISP) where you have an internet account, also offers 'personal web space', a couple of megabytes disk space on its server where you can put your own web site.
Problem : how do you get them there ?
You use FTP : file transfer protocol., an internet protocol designed exactly for things like that : copying files (in this case : your web pages) from one computer to another, over an internet connection. You can use an FTP program such as CuteFTP (shareware), it can be done in a DOS session as well. If you can connect your computer to the internet, you'll most likely be able to start an FTP session, and that's all you need to upload files (web pages) to a (web) server.
Typically, you'll have your own web pages in a folder (directory) on your computer - say, C:\my_site, and you'll want to upload them to the directory on your ISP's server that has been assigned to you. Later on, after you've updated your web pages on your local computer, you will again want to upload them from the same local 'my_site' directory to your ISP's server.
This offers possibilities to automate things quite a lot, since it's in fact repeating the same actions over (and over) again. Scripting comes to mind. Scripting is in fact make a list of commands and have a computer or a computer program execute them.
For a quick introduction on how to run an FTP session at the dos prompt, look here.
note that mput does not upload directories, only files. You need to create the (remote) directories with mkdir, and make sure that the local directory (on your own computer) matches the remote directory (on the remote server) you are uploading to. So to go to an other directory, you have to do both lcd (local) and cd (remote).
The mkdir directory can remain in the script. The second time you run the script, the server will reply 'Directory already exists', and move on to the next command.
Note the 'prompt' command in the script. With 'prompt' you state whether or not you want to be prompted when executing multiple commands. E.g. When 'prompt is On', you will be asked to confirm the upload of every single file, by typing y or n. Like this :
When running a script, you won't have the oportunity to enter the y or n. Besides, the script will already offer the next statement to ftp, while tit is still waiting for a reply to its question. This may cause your upload to fail. It is therefore better to have 'prompt is Off'. To do so, type 'prompt' before you run the script. you will get 'prompt is Off' or 'prompt is On'. You want it on, the prompt statement in the script will turn it off : the status of prompt changes every time you give the prompt command.
You may add another prompt statement at the end of the script. This will turn prompting back on.
FTP uploads can be done in ASCII mode or BINARY mode. ASCII mode is usually OK for text files (web pages, html, ...). Uploading .gif or .jpeg files in ASCII mode may corrupt the files, so this is usually done in Binary mode. The command BIN forces a binary upload.
If you don't force BIN upload for non-text files, they may get uploaded in ASCII mode, which you don't want. There are a couple of workarounds :
the 'hash' statement results in a ###### kind of progress bar for your upload.
You can ask information with the command 'status' : this will tell you whether prompting is on or off, hash enabled or disabled, binary or ascii mode, ...
With the DOS command DIR C:\MyWebSite /AD /S /B > textfile you create a textfile containing all the directories and subdirectories of C:\MyWebSite. When you edit in cd, lcd and mput *.*, you have the main part of your script to upload a complete website. This editing can also be done in a word processor or even a spread sheet, where you can use functions such as copy/paste, find and replace, sort, etc. to make things easier.
The /AD option works in DOS 7.x (Windows 95, 98, ...). It may not be available in earlier DOS versions. I seem to remember there was a /T option for DIR 'directories only'. Or else there's the THREE command (no longer available in DOS 7.x) to list the directory structure, which can be used in a similar way as DIR /AD. Look up DOS help in the Operating Systems section of this site.
Linux users probably have similar commands and redirection methods to make these lists, and text editing and processing tools to edit them into (part of) an ftp script. (here's an example of an ftp script for Linux).
The output of the DIR command will result in a text file that contains a directory structure, like this :
H:\newdev\sillysoft\main H:\newdev\sillysoft\proxy H:\newdev\sillysoft\samples H:\newdev\sillysoft\regbu H:\newdev\sillysoft\ftp H:\newdev\sillysoft\installdos H:\newdev\sillysoft\samples\autoex H:\newdev\sillysoft\main H:\newdev\sillysoft\proxy H:\newdev\sillysoft\samples H:\newdev\sillysoft\regbu H:\newdev\sillysoft\ftp H:\newdev\sillysoft\installdos H:\newdev\sillysoft\samples\autoex
You'll need to edit this a bit (copy it a couple of times, sort, search and replace, ..., add username and password, add other commands like hash, prompt, bin) into a script (let's say 'script.txt') that looks like this :
johnnyBgoode mysecretpassword prompt bin hash pwd cd / mput *.* mkdir ftp cd ftp lcd h:\newdev\sillysoft\ftp mput *.* cd / mkdir installdos cd installdos lcd h:\newdev\sillysoft\installdos mput *.* cd / mkdir main cd main lcd h:\newdev\sillysoft\main mput *.* cd / mkdir proxy cd proxy lcd h:\newdev\sillysoft\proxy mput *.* cd / mkdir regbu cd regbu lcd h:\newdev\sillysoft\regbu mput *.* cd / mkdir samples cd samples lcd h:\newdev\sillysoft\samples mput *.* cd / mkdir samples\autoex cd samples\autoex lcd h:\newdev\sillysoft\samples\autoex mput *.* cd / prompt byeAt the dos prompt, you then start an ftp session with the ftp server of your internet provider (in this example, the provider is Yoohoo, their ftp server is called ftp.yoohoo.net)
c:\ my_site>ftp ftp.yoohoo.net -s:script.txt
open ftp.yoohoo.netas first line in the script, and start the ftp session with
c:\ my_site>ftp -s:script.txt. One way or another, it should work, and you'll see the files being uploaded. On the screen, this will look like this :
And after a couple of weeks or months, when you've made changes to your website, you can take the same script, add or remove a few lines if necessary, and run it again to update your site. Or you can create several scripts, for different web sites at multiple providers. Or separate scripts, one for html upload and one for pictures etc. After all, once you've uploaded the pictures, they stay there, you don't need to include them again when you just want to upload a new or updated html file.
Enjoy.