- or download this
my $atime = $info->atime; # time of last access (seconds since epoch)
my $mtime = $info->mtime; # time of last data modification
my $ctime = $info->ctime; # time of last file status change
- or download this
# if no argument given, default to current directory
my $startdir = cwd();
...
$startdir = "@ARGV";
# convert /usr/bin to _usr_bin for filename
($startdir = $startdir) =~ s/\//_/g;
- or download this
my $startdir = $ARGV[0] || cwd();
$startdir =~ s/\//_/g;
- or download this
# get the current date to append to output filename
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim
+e);
...
if ( $cday < 10 ) { $cday = "0" . $cday; }
my $cdate = "_$cday" . "_$cmonth" . "_$cyear";
$txtfileout = "permrestore" . $startdir . $cdate;
- or download this
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim
+e);
my $txtfileout = sprintf "permrestore%s_%02d_%02d_%04d", $startdir, $m
+day, $mon, $year;
- or download this
use POSIX qw( strftime );
my $txtfileout = strftime "permrestore" . $startdir . "_%d_%m_%Y", loc
+altime;
- or download this
# subroutines
sub time_as_date($)
...
my $date = localtime($time);
return $date;
}
- or download this
my $size = $info->size; # size in bytes
# ...
my $adate = time_as_date($atime);
my $mdate = time_as_date($mtime);
my $cdate = time_as_date($ctime);
- or download this
my $perms = sprintf("%04o", $mode & 07777);
# ...
print "\# ORIG PERM = $filename\t$uid\t$gid\t$perms\t$mdate";
- or download this
sub time_as_date($)
# ...
sub print_info($)
- or download this
use File::Find ();
# ...
sub find(&@) { &File::Find::find }
- or download this
*name = *File::Find::name;
- or download this
*name = \$File::Find::name;
- or download this
print "\n Do you want to continue (y/n)? ";
$answer = <STDIN>;
- or download this
#!/usr/bin/perl
use strict;
...
print "chmod $perms $filename\n";
print "chown $uid:$gid $filename\n";
}, @ARGV ? @ARGV : '.';
- or download this
#!/bin/bash
if [ "$1" ] ; then DIR="$1" ; else DIR="$PWD" ; fi
SCRIPT="permrestore${DIR//\//_}$( date +_%d_%m_%Y )";
permrestore "$DIR" | tee "$SCRIPT"
chmod a+x "$SCRIPT"
- or download this
#!/bin/bash
...
find "$DIR" -printf "$FORMAT" | tee "$SCRIPT"
chmod a+x "$SCRIPT"