Absolute Path List
apls.pl is a simple Perl script to list directory contents but with forced absolute file paths. Other Pikt scripts might invoke the apls.pl script, for example, ClearTmp.
As with other scripts, we source this script from the programs.cfg PIKT configuration file (or perhaps an apls_programs.cfg #include file; not shown). The end-use, target script follows.
#!/usr/bin/perl # apls.pl -- absolute path ls die "Usage: apls.pl \n" if $#ARGV != 0 ; $DIRLIST = $ARGV[0] ; die "$DIRLIST not found!\n" if ! -e $DIRLIST ; $LSCMD = "/bin/ls -lA" ; open(DIRLIST, $DIRLIST) ; while () { chop; $dir = $_ ; chdir($dir) ; open(LSCMD, "$LSCMD 2>/dev/null |") ; while () { next if /^total/ ; if (/^(\D+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$/) { printf "%s %s %s %s %s %s %s %s/%s\n", $1, $2, $3, $4, $5, $6, $7, $dir, $8 ; } elsif (/^(\D+)\s*(\d+)\s+(\S+)\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)\s*$/) { printf "%s %s %s %s %s %s %s %s %s/%s\n", $1, $2, $3, $4, $5, $6, $7, $8, $dir, $9 ; } } close(LSCMD) ; } close(DIRLIST) ;
For more examples, see Samples.