|
Sharing Files and Creating Form Letters |
|
By Ray Swartz Questions regarding this column should be sent to the author at ray@cse.ucsc.edu. Jeyakesavan Veerasamy would like to share files with other users on his system without giving them complete access to this entire directory hierarchy. A directory of shared files can be created by using links. Karl Kulling wants to combine addresses with a letter file to create form letters. I provide two solutions, one running Awk, the other Perl. A Trip to the LinksQuestion: I have a multi-level directory structure
under my home directory. If I want to make the lowest-level
directory files visible or accessible to others, not only do I
have to give proper permissions for the files in that directory,
but also I have to provide execute (search) permission for all
directories on the path to reach that directory, which I would
prefer not to do. For example, if I want to make the files in
Answer: UNIX system files consists of two parts: an inode and a name. The inode holds all the information about the file, including--among other things--the file's owner, work group, permissions, size, and a list of file blocks that belong to this file. A directory entry associates the inode with a file name. File inodes are identified by number with the directory
mapping the inode number to the name. You can list the file name
-inode number pairs by specifying the The inode number for a file doesn't change after the file is
created. That is, the file's contents are associated with a
specific inode, and that inode will always refer to that file's
data. By contrast, the file's name can be changed easily (for
instance, by using the In fact, a Unix file can have more than one name. More
accurately, a file's inode can have several links. A new link to
a file is created with the Because a link connects a name to an inode number, every link will represent the same file. In other words, every link will have the same permissions, owner, work group, file times and all other file-related information, with one exception--the name. Each link identifies the file with its assigned name. The inode must keep track of the number of links that have been connected to it. Without this knowledge, the system wouldn't know when the last link to a file was removed so it can recycle the inode and any allocated blocks. The best place to keep this link count information is in the inode itself. Every time a link to an inode is added (say, with
A file's link count is displayed in the second column of
output from the The solution to your problem is creating links to the files that you wish to share in the directory where you want them to be visible. This way, any user with the appropriate access to the "sharing" directory can access or copy the files you want to make available to them. Note that you will have to give the users in question search and read access to the "sharing" directory. Also, the files will have to have proper permissions assigned to them so that users can view and copy them. Listing 1C shows an
example. Here, the directory Open A Mailing FrequencyQuestion: I have a data base of addresses where each
address is one line long. The fields on the line are separated
by colons ( Answer: I've provided two ways to produce the output you request. One is with a shell script that primarily depends on the Unix Awk utility. The other is a Perl program. I've provided both to demonstrate two different ways to do the same task. The basic design is to read the letter into an array and then to process the addresses. For each address, a formatted letter is sent to the standard output. Both programs take exactly two arguments. The first one is the name of the form letter file and the second is the address data base file name. The Awk version, named The The Perl version, named |
Print This Page Send as e-mail |












