Win commands help automate downloading files |
Every day, the Internet is becoming more influential to the way business is done. You might think that some of the Windows tools used to transfer files across the Net would be easier to find and use. Most of us who surf the Web have probably clicked a link on a Web site to download a shareware utility, a text file, or some other resource. But most Web users probably don't know about a simple way to automate the process of downloading (or uploading) files. For this task, Microsoft includes in Windows 98, Windows NT, and Windows 2000 a program called ftp. This program supports the File Transfer Protocol, or FTP, an Internet standard for moving data from one place to another. When you click a Web link to download a file, it's likely that the transfer is done using FTP. Unfortunately, ftp is a text-mode command, and there's nothing in the Windows 98 Help system that mentions anything about ftp. The program is listed in the Windows NT and Windows 2000 Help, but there's almost nothing about using it to automate your routine tasks. Reader Bob Nolte finds the automation aspects of ftp extremely useful. He uses ftp to download weekly updates of antivirus definition files for his clients' networks. To automate the process on networks that may support hundreds of PCs, he uses a tiny script file on NT Server. If you've never used the ftp program, its command-line syntax looks like this: ftp {options} {-s:filename} {hostname} For details about this syntax, open a DOS window and type ftp -? (using /? doesn't work). Or type ftp into the Index box in Windows NT or 2000 Help, then click Display. Typing ftp at a command-line prompt starts an FTP session. You can then type commands interactively to connect to a remote host, access its resources, and then disconnect using the bye command. In order to use ftp, you must be using a computer that has the TCP/IP protocol installed. Nolte uses a small batch file called download.bat, which automates his antivirus updates. This batch file connects to an Internet host that we'll call ftp.getfiles.com. In the batch file shown below, the FTP program reads a script file called down.txt. That script downloads an anti-virus definition file called update.exe. All of this is logged to another text file called ftp.log. Nolte can check this log to make sure everything worked properly. The contents of download.bat look like this: d: cd \data echo Start of download>ftp.log ftp -s:down.txt ftp.getfiles.com>>ftp.log echo End of download>>ftp.log In the above batch file, the redirection sign (>) in line 3 creates a new ftp.log text file. In lines 4 and 5, the append sign (>>) adds output text to this file. Nolte's script file, down.txt, contains the following commands, which ftp executes on the remote host. The first two lines enter an ID and password. The script then changes directories, downloads update.exe, closes the session with the host, and exits. anonymous me@nonet.com cd pub/software lcd d:\data bin hash get update.exe close bye Nolte points out that this method is just as useful for uploads as it is for downloads. This makes it handy for any situation in which you must exchange files with a host regularly. - Brian Livingston |
Category:Windows Manager Issue: November 1999 |
These Web pages are produced by Australian PC World © 1999 IDG Communications