This content is no longer maintained. Please visit our new website.

ACCC Home Page Academic Computing and Communications Center  
Accounts / Passwords Email Labs / Classrooms Telecom Network Security Software Computing and Network Services Education / Teaching Getting Help
 
File Transfer and FTP/sFTP
0. Contents 1. File Transfer: Which type should you use? 2. Intro to FTP 3. Web Publishing via FTP 4. FTP Details 5. Related Links

Web Publishing Without UNIX

     
 
     
A Real Life Example of FTP
  Say that you've been toying with the idea of publishing your own World Wide Web home page. You can, and it's probably easier than you think. You will have to open your ACCC UNIX account and you will also have log into it at least once, to create a public_html directory in your root directory and give everyone read and execute access to it, and to use phupdate to have your Web page listed in your ph directory listing.

But you can do the rest of your work -- creating, testing, and updating your Web pages -- on your desktop machine, and then transfer the files, with FTP of course, to tigger (or icarus) over that ADN. The FTP demons running on the ACCC UNIX machines have a set of UNIX-specific commands that make this possible.

How you'll actually move the files from your personal computer to your UNIX account depends on what your local machine is, how it's networked (it must be connected to the UIC network in some way -- either by a direct connection or UIC-Wireless on campus or with another type of Internet connection from off-campus -- for this to work), and what sort of FTP software you have. Hopefully, you'll have a nice, friendly GUI FTP to make everything easy for you. But even if you do, it pays to know exactly what you're asking it to do.

So here they are, the actual line-at-a-time FTP commands you'd use to move the files for your Web page from your personal computer to the public_html directory on your ACCC UNIX account.

 
     
Setting the Stage
  Let's assume that your desktop machine is connected in some way to the UIC ADN-ii campus network. (You could also use SLIP or PPP through an ACCC full Internet access dialup telephone connection or use any machine in an ACCC microcomputer lab.) To make it really concrete, let's assume that your ACCC UNIX account is on tigger, your netid (and tigger login id) is adabyron, and you're starting your Web page with three files, two HTML files: home.htm (which is your home page HTML file) and aboutme.htm, and one (binary) image, mymug.gif.

The first step doesn't have anything to do with FTP, so let's call it Step 0.

 
     
Step 0. Test your Web page on your desktop machine.
  There will be some way to load a local file into your Web browser; it might be in the Filemenu, if your browser has one, or your browser might accept the file’s name in a URL beginning with file:/// (file:///c\html\home.htm for example; yes, these are three slashes). When you think your HTML file is ready, check to make sure that its links will work when you move it to tigger. (You might change the filename, directory, or extension when you transfer it; if you do, you'll also have to change the href of any anchor pointing to it. You can minimize these changes if you use relative rather than absolute addressing in your anchors.)  
     
Step 1. Begin FTP.
  Start FTP on your local machine and open a connection to the remote host machine -- tigger.cc.uic.edu in this case: ftp tigger.cc.uic.edu
(If your ACCC UNIX account is on icarus, just substitute icarus for the tigger.) When prompted, enter your netid and ACCC UNIX password. If all has gone well, your FTP software will now be talking to tigger's FTP demon.
 
     
Step 2. Move to the correct directory.
  Before you actually copy any files, make sure you're working in the correct directories, both on tigger and on your local machine. Your default "working directory" when FTPing to tigger is your own home directory on tigger, ~adabyron in this example, so you have to "change directories" to your public_html directory, enter: cd public_html

To see a list of files already in the working directory on tigger (the remote machine), enter the FTP command: dir
The list of files returned from tigger should look like the lists returned by the UNIX ls -l command. If the list you get is too long, you can probably tell dir to put it into a file on your personal computer that you can browse; look at the online help for your FTP's dir command to see how.

If you forget what directory you're working with on tigger (the remote host), enter: site pwd (print working directory).

There will also be some way that you can list the files in the current directory of your local machine while you're using FTP. If your operating system supports multiple windows, you probably can just use your normal file management utility in a different window. Or your FTP GUI might do it for you. At least there will be either a command or a character that you can type at FTP's prompt that will allow you to temporarily return from FTP to your local machine's operating system; use it and then enter the command you would normally use to get a list of your files.

To change to a different directory on your local machine at the FTP prompt, enter: lcd localdirectory where localdirectory is the name of the directory on your local machine where you want the files stored.

 
     
Step 3. Set UNIX file permissions for the files you're going to transfer.
  You want the public to be able to read your Web files, but only you (their owner) should be able to "write" them. So the permissions you want are read/write permissions for owner, and read only for group and others; that's umask 022. The FTP demon we run on the ACCC UNIX machines has a special command that you use with site to set the umask for the files you transfer: site umask 022
(For your own files, you'll want 077, read and write only for the owner; if you're working on a departmental home page with other members of your department's WWW group, you'll want 002, read for everyone, write for owner and group.) If you forget to set the umask ahead of time, that's OK too, just use: site chmod 022 remotefile
 
     
Step 4. Transfer the files.
  First, set the transfer type for each file. The HTML files are "ascii" or text files (files that people -- not just programs -- can read). But the .gif file isn't ascii; it's "binary." (Executable and/or compressed files like .zip, .z, .gz, and .tar files are binary too.) One command tells both your FTP software and the remote FTP demon the type of transfer: ascii for text files, and for binary files it's often binary or it might be octet or image. Check your FTP's manual or online help.

Then put a copy of the file from your local machine to the remote machine: put localfile remotefile
This sends a copy of the file on the local host machine with the name localfile to the remote machine with the name remotefile. You can leave remotefile out if you want to keep the same name (and the same case). When the file's name has two or more parts, the parts of the name must be separated by periods, name.extension for example. (Even CMS fileids.) Use the get command to copy a file from the remote host to your local host, see the box More About get and put for more information.

For simplicity, the names of the transferred files should be lowercase, so type them all in lower case. The URL for your home page will be simplified if its name is index.html. (Then the URL would be http://www.uic.edu/~adabyron/ instead of http://www.uic.edu/~adabryon/home.html; on icarus use www2.uic.edu instead of www.uic.edu.) We're using the same name for the GIF file, so we can leave out the remote file name. So the commands are:

        
cd public_html 
site umask 022 
ascii 
put home.htm index.html 
put aboutme.htm aboutme.html 
binary 
put mymug.gif 
dir
 
     
Step 5. Leave FTP.
  This is another place where the FTP software you're using will really make a difference. If you're using a graphical FTP interface, there will probably be menu items to close your current connection, to open a new one if you want, and to exit the program. If you're using a line-at-a-time FTP command interface, enter the FTP quit command to close your connection to the remote machine and then to leave FTP. To just close the current connection and open another, enter: close and then: open remotename (or connect remotename )

And that's it. All that's left is testing your Web page and its links again. And you don't need UNIX to do that.

 
     
More About get and put
  In the examples in Step 4, we used the FTP put command to copy files from your local machine to the remote machine. To go the other way -- to copy a file from the remote machine to your local machine -- use the FTP get command; enter: get remotefile localfile where remotefile and localfile are, respectively, the name the file has on the remote machine and the name the file will have on the local machine.

If you're transferring multiple files, you might prefer to use mget and mput. For example, you could use: mput *.htm to initiate the transfer to the remote host of all local files with any name ("*") the .htm extension. FTP will build the name for the transferred file on the destination machine from the file's original name. (Since you want to change the case in the names of the transferred files, mput isn't much good here.)

Many implementations of FTP (but unfortunately not the one on UICVM CMS) have a command that instructs mget and mput to allow you to say (usually by responding y or n to a prompt) whether you want to transfer each individual matching file, and perhaps to select the name for the transferred copy. Sometimes this command is prompt or toggle prompt
Look for it in the manual or online help for your FTP.

 
FTP/sFTP File Transfer Previous:  2. Intro to FTP Next:  4. FTP Details


2010-5-20  ACCC documentation
UIC Home Page Search UIC Pages Contact UIC