Perl 101: FTP | WebReference

Perl 101: FTP

FTP

Perl 101

The first thing you need to do before you begin working on the program is to properly understand your FTP software. A large percentage of the errors encountered when installing a Perl program come from improper use of the FTP program (telnet will not be covered). Your FTP software is a crucial component of installing a Perl program as it is what enables you to assign the program the appropriate permissions or security settings. The permissions of programs or files tells the server what the file is capable of doing or not doing. For example, if I want to write a program that modifies a text file, I need to set the permissions accordingly for the specified text file. If they are set incorrectly the server will not be able to write or append data to it. Almost all of the interfaces of the various FTP programs are strikingly similar. Under most circumstances, we will select a file or folder, usually just by clicking on it once to highlight it, and then go to one of our menu items to access our file permission settings. We want to find the command labeled "file attributes" or "permissions." This will bring up a dialog box that will present us with a series of check boxes for Owner, Group, and Public permissions. These three different categories allow you to specify permissions for each category of Read, Write or Execute.

If we break these down numerically, the number 4 means read, the number 2 means write and the number 1 means execute. You add these numbers together to grant or give permissions to each category (Owner, Group, or Public). If we were to chmod xyz somefile.txt (normally you would chmod or set a program's permission to 755), the owner’s permissions are defined by the x number, group permissions are defined by y, and z refers to everyone else or the public. Let’s take this a step further and say that we want to chmod 755 somfile.txt. We are giving the owner 7 (4 + 2 + 1 = read/write/execute), the group 5 (4 + 1= read/execute), and everyone 5 (4 + 1 = read/execute). Let’s plug this into our matrix to better understand what it is we are doing:

Owner (x) Group (y) Everyone (z)
Read (Value of 4) x x x
Write (Value of 2) x
Execute (Value of 1) x x x
chmod (4+2+1) 7 (4+1) 5 (4+1) 5 chmod = 755

As you see in the below screen shot of CuteFTP you select and deselect the various boxes to set the appropriate permissions very similar to the above matrix.

CuteFTP Permissions
CuteFTP Screen Shot "Changing File Attributes"

Your only other immediate concern when using an FTP program is to set the correct transfer settings. You want to transfer your files to the server in ASCII or text format. This is usually under the transfer settings on your menu. If you leave it at the default "Automatic" setting it will often send your files in Binary format, which will produce an internal server error. I am assuming that you have enough experience with GUIs (Graphical User Interfaces) to figure out how to transfer your files. Most programs these days support simple drag-and-drop operation, otherwise consult your manual.

Comments are welcome


Revised: May 8, 1998

URL: https://webreference.com/programming/perl/101/ftp.html