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.

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
See how to
automatically report
network service failures