98N/A<!
DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
98N/A<
META NAME="generator" CONTENT="troff2html (AT&T Labs Research) 04/01/97 -mm">
98N/A<
PRE><
CENTER><
H2>A Tour of the ast Commands and Libraries</
H2><
H4>
98N/AAT&T Labs - Research
98N/AMurray Hill, NJ 07974
98N/A<
H3><
A NAME="1Introduction">1 Introduction</
A></
H3>
98N/AThe <
EM>ast </
EM>commands and libraries were developed by the Software Engineering
98N/AResearch Department (<
EM>aka </
EM>the Advanced Software [Technology] Department)
98N/Aat AT&T Bell Laboratories, Murray Hill, NJ.
98N/AThe strength of <
EM>ast </
EM>is how its individual components combine to form a
98N/Acohesive computing environment across UNIX<
SUP>®</
SUP> and non-UNIX platforms.
98N/A<
A HREF="#FN577">Cohesiveness*</
A><
FN ID="FN577">Footnote test.
98N/A</
FN>is maintained by well-defined library interfaces for algorithms upon which
98N/Athe commands are built.
98N/AIn many cases a library implementation was the driving force behind command
98N/A<
H3><
A NAME="2Motivation">2 Motivation</
A></
H3>
354N/AWhy should you consider using the <
EM>ast </
EM>software? After all, many of the
354N/AAlthough there is some replication, there are also some commands you won't
354N/Afind anywhere else: <
EM>the </
EM>ksh93, nmake, the 3d filesystem, cia, and yeast.
354N/A<
H3><
A NAME="3Installation">3 Installation</
A></
H3>
354N/AThe <
EM>ast </
EM>software installs in a single directory hierarchy, rooted at <
TT>$INSTALLROOT</
TT>,
98N/AThe top level <
TT>$INSTALLROOT </
TT>directories are: <
PRE>
98N/A<
TT> bin executable binaries and scripts
98N/A fun </
TT><
EM>ksh93</
EM><
TT> shell functions
98N/A lib/</
TT><
EM>command</
EM><
TT> related files for </
TT><
EM>command</
EM><
TT>
98N/A src/
cmd/</
TT><
EM>xxx</
EM><
TT> source for command </
TT><
EM>xxx</
EM><
TT>
341N/A src/
lib/
lib</
TT><
EM>xxx</
EM><
TT> source for library </
TT><
EM>xxx</
EM><
TT>
366N/A</
TT></
PRE>To access the commands and related data files: <
PRE>
425N/A</
TT></
PRE>For each <
EM>command </
EM>that has a related data file <
EM>file</
EM>, <
EM>file </
EM>is found by searching
354N/Aoverride standard <
EM>ast </
EM>related files by placing them in the directory This
278N/Aallows executables to be built without hard-coded pathnames and also requires
98N/Aonly a change in <
TT>$PATH </
TT>when <
TT>$INSTALLROOT </
TT>changes.
543N/AOn systems with shared libraries one of <
PRE>
137N/A</
TT></
PRE>is required to locate the <
EM>ast </
EM>shared libraries.
179N/A<
H3><
A NAME="4Exploration">4 Exploration</
A></
H3>
126N/Acombines <
EM>find </
EM>and <
EM>xargs</
EM>.
98N/AIt provides C style expressions on path names and elements of <
TT>struct stat</
TT>.
98N/ATo find suspicious executables: <
PRE>
543N/A<
TT> tw -d / -e "uid=='root' && (mode&'u+s') &&
parent.uid!=uid"
543N/A</
TT></
PRE>to change the owner of all of bozo's files: <
PRE>
98N/A<
TT> tw -d / -e "uid=='bozo'" chown clown:circus
287N/A</
TT></
PRE><
EM>tw </
EM>collects file pathname arguments up to the exec arg limit before it
499N/AFor paranoid users: <
PRE>
98N/A</
TT></
PRE>which is equivalent to: <
PRE>
98N/A<
TT> chmod -R go-rwx
98N/A</
TT></
PRE>(Now you don't need to add a <
TT>-R </
TT>option to your favorite commands.) To find
98N/Aall source files that include <
TT>
foo.h</
TT>: <
PRE>
498N/A<
TT> tw -e "name=='*.[chly]'" grep -l '^#.*include.*["<]
foo.h[>"]'
498N/A</
TT></
PRE><
EM>libast </
EM>handles the magic number matching for the <
EM>file </
EM>command.
98N/Agive the same output across all architectures: <
PRE>
98N/A</
TT></
PRE>might produce: <
PRE>
493N/A</
TT></
PRE><
EM>tw </
EM>uses the same interface, making it easy to search for files based on
The following searches for executable scripts: <
PRE>
<
TT> tw -e "(mode&'+x') && type!=DIR && magic!='*executable*'"
</
TT></
PRE>The <
EM>tw </
EM>algorithm efficiently detects file system loops, so following symbolic
The same algorithm is used by all <
EM>ast </
EM>commands that traverse directory
hierarchies, and the following options to control pathname resolution:
<
PRE><
TT> -L (logical) follow symbolic links
-P (physical) don't follow symbolic links
-H (metaphysical) -L for command line files, -P otherwise
</
TT></
PRE>The <
EM>ksh93 </
EM><
EM>getconf </
EM>builtin controls the default traversal mode: <
PRE>
<
TT> getconf PATH_RESOLVE - { logical, physical, metaphysical }
<
H3><
A NAME="5Configuration">5 Configuration</
A></
H3>
<
H3><
A NAME="6Compression">6 Compression</
A></
H3>
<
H3><
A NAME="7Conclusion">7 Conclusion</
A></
H3>