Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Ole Tange
tangetools
Commits
96f2c1c2
Commit
96f2c1c2
authored
May 23, 2016
by
Ole Tange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makefile: Use template.
parent
3320b47c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
427 additions
and
236 deletions
+427
-236
Makefile
Makefile
+4
-25
rrm/rclean
rrm/rclean
+57
-0
rrm/rrm
rrm/rrm
+84
-0
timestamp/timestamp.1
timestamp/timestamp.1
+23
-14
tracefile/tracefile
tracefile/tracefile
+195
-0
tracefile/tracefile.pod
tracefile/tracefile.pod
+0
-197
wssh/wssh
wssh/wssh
+64
-0
No files found.
Makefile
View file @
96f2c1c2
all
:
blink
/blink.1
histogram
/histogram.1 upsidedown/upsidedown.1 tracefile/tracefile.1 timestamp/timestamp.1 rand/rand.1 rrm/rrm.1 goodpasswd/goodpasswd.1
CMD
=
blink histogram
upsidedown tracefile timestamp rand rrm goodpasswd
blink/blink.1
:
blink/blink
pod2man blink/blink
>
blink/blink.1
all
:
blink/blink.1 goodpasswd/goodpasswd.1 histogram/histogram.1 rand/rand.1 rrm/rrm.1 timestamp/timestamp.1 tracefile/tracefile.1 upsidedown/upsidedown.1 wssh/wssh.1
goodpasswd/goodpasswd.1
:
goodpasswd/goodpasswd
pod2man
goodpasswd/goodpasswd
>
goodpasswd/goodpasswd.1
%.1
:
%
pod2man
$<
>
$@
histogram/histogram.1
:
histogram/histogram
pod2man histogram/histogram
>
histogram/histogram.1
rand/rand.1
:
rand/rand
pod2man rand/rand
>
rand/rand.1
rrm/rrm.1
:
rrm/rrm
pod2man rrm/rrm
>
rrm/rrm.1
timestamp/timestamp.1
:
timestamp/timestamp
pod2man timestamp/timestamp
>
timestamp/timestamp.1
tracefile/tracefile.1
:
tracefile/tracefile.pod
pod2man tracefile/tracefile.pod
>
tracefile/tracefile.1
upsidedown/upsidedown.1
:
upsidedown/upsidedown
pod2man upsidedown/upsidedown
>
upsidedown/upsidedown.1
wssh/wssh.1
:
wssh/wssh
#pod2man wssh/wssh > wssh/wssh.1
install
:
mkdir
-p
/usr/local/bin
...
...
rrm/rclean
0 → 100755
View file @
96f2c1c2
#!/usr/bin/perl
use
Digest::MD5::
File
qw(dir_md5_hex file_md5_hex url_md5_hex)
;
my
$dir
=
shift
||
"
.
";
chdir
$dir
;
# Table of which files have a given size
open
(
IN
,"
-|
",'
find "`pwd`" -type f -printf "%s\t%p\0"
')
||
die
;
$/
=
"
\
0
";
my
%size
;
while
(
<
IN
>
)
{
chop
;
# Remove \0
my
(
$s
,
$f
)
=
split
/\t/
,
$_
;
push
@
{
$size
{
$s
}},
$f
;
}
close
IN
;
# Read md5sum of removed files of a given size
my
%rrm
;
my
$rrmfile
=
find_rrm_file
("
.
")
||
"
.rrm
";
open
(
RRM
,"
<
",
$rrmfile
)
||
die
;
while
(
<
RRM
>
)
{
my
(
$size
,
$md5
,
$file
)
=
split
/\t/
,
$_
;
$rrm
{
0
+
$size
}{
$md5
}
++
;
}
close
RRM
;
# Which existing files are the same size as some of the removed files?
for
my
$size
(
keys
%rrm
)
{
for
my
$file
(
@
{
$size
{
$size
}})
{
if
(
-
e
$file
)
{
my
$md5
=
Digest::
MD5
->
new
;
$md5
->
addpath
(
$file
);
# Do they have the same md5sum?
if
(
$rrm
{
$size
}{
$md5
->
hexdigest
})
{
# remove this
print
"
$file
\n
";
}
}
}
}
sub
find_rrm_file
{
my
$dir
=
shift
;
if
(
-
r
"
$dir
/.rrm
")
{
return
"
$dir
/.rrm
";
}
if
(
join
("
",
stat
$dir
)
eq
join
("
",
stat
"
$dir
/..
"))
{
# root
return
undef
;
}
else
{
return
find_rrm_file
("
$dir
/..
");
}
}
rrm/rrm
0 → 100755
View file @
96f2c1c2
#!/usr/bin/perl
=encoding utf8
=head1 NAME
rrm - record and remove file
=head1 SYNOPSIS
B<rrm> I<file>
=head1 DESCRIPTION
B<rrm> records a file's MD5sum before removing it. It makes it
possible to automatically remove the file again should it ever
reappear.
This is useful for cleaning up photos where other partial backups of
the photos are later added: Photos removed once can easily be
identified and removed automatically if added by the backup.
=head1 EXAMPLE
B<rrm> IMG_2035.JPG
Restore a backup containing I<IMG_2035.JPG>.
B<rclean>
B<rclean> will find B<IMG_2035.JPG> as it has the same size and MD5sum
as an already removed file.
=head1 FILES
The file B<.rrm> contains the database of size, md5sum, and names of
the files. It is created in current directory if it cannot be found in
any of the (grand*)parent directories.
=head1 SEE ALSO
B<rclean>(1), B<rm>(1), B<md5sum>(1)
=cut
use
Digest::MD5::
File
qw(dir_md5_hex file_md5_hex url_md5_hex)
;
my
%size
;
my
%md5
;
for
my
$file
(
@ARGV
)
{
if
(
-
s $file > 0) {
$size{$
file
}
=
-
s $file;
my $md5 = Digest::MD5->new;
$md
5
->
addpath
(
$file
);
$md5
{
$file
}
=
$md5
->
hexdigest
;
}
}
$rrmfile
=
find_rrm_file
("
.
")
||
"
.rrm
";
open
(
RRM
,"
>>
",
$rrmfile
)
||
die
("
Cannot write to
$rrmfile
.
");
print
RRM
map
{
$size
{
$_
}
.
"
\t
"
.
$md5
{
$_
}
.
"
\t
"
.
$_
.
"
\
0
\n
"
}
@ARGV
;
close
RRM
;
unlink
@ARGV
;
sub
find_rrm_file
{
my
$dir
=
shift
;
if
(
-
r
"
$dir
/.rrm
")
{
return
"
$dir
/.rrm
";
}
if
(
join
("
",
stat
$dir
)
eq
join
("
",
stat
"
../
$dir
"))
{
# We have reached root dir (.. = .)
return
undef
;
}
else
{
return
find_rrm_file
("
../
$dir
");
}
}
timestamp/timestamp.1
View file @
96f2c1c2
.\" Automatically generated by Pod::Man 2.2
5
(Pod::Simple 3.
16
)
.\" Automatically generated by Pod::Man 2.2
7
(Pod::Simple 3.
28
)
.\"
.\" Standard preamble:
.\" ========================================================================
...
...
@@ -38,6 +38,8 @@
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
...
...
@@ -48,17 +50,24 @@
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.
ie \nF \{
\
.
de IX
.
tm Index:\\$1\t\\n%\t"\\$2"
.\
"
.
\" Avoid warning from groff about undefined register 'F'.
.
de IX
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
...
...
@@ -124,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "TIMESTAMP 1"
.TH TIMESTAMP 1 "201
4
-0
2-14
" "perl v5.1
4
.2" "User Contributed Perl Documentation"
.TH TIMESTAMP 1 "201
6
-0
5-23
" "perl v5.1
8
.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
...
...
@@ -145,10 +154,10 @@ and now.
If \fB\-\-delta\fR is repeated: The time spent between each line.
.IP "\fB\-\-rfc\fR" 9
.IX Item "--rfc"
Output time format in \s-1RFC822\s0
(E.g. Wed, 30 Jan 2013 13:57:58 \s-1GMT\s0).
Output time format in \s-1RFC822
\s0(E.g. Wed, 30 Jan 2013 13:57:58 \s-1GMT\s0).
.IP "\fB\-\-iso\fR" 9
.IX Item "--iso"
Output time format in \s-1ISO8601\s0
(E.g. 2013\-01\-30T13:57:58.322).
Output time format in \s-1ISO8601
\s0(E.g. 2013\-01\-30T13:57:58.322).
.IP "\fB\-\-iso\-time\fR" 9
.IX Item "--iso-time"
Output time format in ISO8601/time only (E.g. 13:57:58.322).
...
...
@@ -179,8 +188,8 @@ the Free Software Foundation; either version 3 of the License, or
at your option any later version.
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT
\s0 \s-1ANY\s0 \s-1
WARRANTY\s0; without even the implied warranty of
\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS
\s0 \s-1FOR\s0 A \s-1
PARTICULAR
\s0 \s-1
PURPOSE\s0
.
See the
but \s-1WITHOUT
ANY
WARRANTY\s0; without even the implied warranty of
\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS
FOR A
PARTICULAR
PURPOSE
.
\s0 See the
\&\s-1GNU\s0 General Public License for more details.
.PP
You should have received a copy of the \s-1GNU\s0 General Public License
...
...
tracefile/tracefile
View file @
96f2c1c2
#!/usr/bin/perl
=head1 NAME
tracefile - list files being accessed
=head1 SYNOPSIS
B<tracefile> [-aenu] I<command>
B<tracefile> [-aenu] -p I<pid>
=head1 DESCRIPTION
B<tracefile> will print the files being accessed by the command.
=head1 OPTIONS
=over 9
=item I<command>
Command to run.
=item B<-a>
List all files.
=item B<-e>
List only existing files.
=item B<-n>
List only non-existing files.
=item B<-p> I<pid>
Trace process id.
=item B<-u>
List only files once.
=back
=head1 EXAMPLES
=head2 EXAMPLE: Find the missing package
Assume you have a program B<foo>. When it runs it fails with: I<foo:
error: missing library>. It does not say with file is missing, but you
have a hunch that you just need to install a package - you just do not
know which one.
tracefile -n -u foo | apt-file -f search -
Here B<ls> tries to find B</usr/include/shisa.h>. If it fails,
B<apt-file> will search for which package it is in:
tracefile -n -u ls /usr/include/shisa.h | apt-file -f search -
=head1 REPORTING BUGS
Report bugs to <tange@gnu.org>.
=head1 AUTHOR
Copyright (C) 2012 Ole Tange, http://ole.tange.dk and Free
Software Foundation, Inc.
=head1 LICENSE
Copyright (C) 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head2 Documentation license I
Permission is granted to copy, distribute and/or modify this documentation
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the file fdl.txt.
=head2 Documentation license II
You are free:
=over 9
=item B<to Share>
to copy, distribute and transmit the work
=item B<to Remix>
to adapt the work
=back
Under the following conditions:
=over 9
=item B<Attribution>
You must attribute the work in the manner specified by the author or
licensor (but not in any way that suggests that they endorse you or
your use of the work).
=item B<Share Alike>
If you alter, transform, or build upon this work, you may distribute
the resulting work only under the same, similar or a compatible
license.
=back
With the understanding that:
=over 9
=item B<Waiver>
Any of the above conditions can be waived if you get permission from
the copyright holder.
=item B<Public Domain>
Where the work or any of its elements is in the public domain under
applicable law, that status is in no way affected by the license.
=item B<Other Rights>
In no way are any of the following rights affected by the license:
=over 2
=item *
Your fair dealing or fair use rights, or other applicable
copyright exceptions and limitations;
=item *
The author's moral rights;
=item *
Rights other persons may have either in the work itself or in
how the work is used, such as publicity or privacy rights.
=back
=back
=over 9
=item B<Notice>
For any reuse or distribution, you must make clear to others the
license terms of this work.
=back
A copy of the full license is included in the file as cc-by-sa.txt.
=head1 DEPENDENCIES
B<tracefile> uses Perl, and B<strace>.
=head1 SEE ALSO
B<strace>(1)
=cut
use
Getopt::
Long
;
$
Global::
progname
=
"
tracefile
";
...
...
tracefile/tracefile.pod
deleted
100644 → 0
View file @
3320b47c
#!/usr/bin/perl
=head1 NAME
tracefile - list files being accessed
=head1 SYNOPSIS
B<tracefile> [-aenu] I<command>
B<tracefile> [-aenu] -p I<pid>
=head1 DESCRIPTION
B<tracefile> will print the files being accessed by the command.
=head1 OPTIONS
=over 9
=item I<command>
Command to run.
=item B<-a>
List all files.
=item B<-e>
List only existing files.
=item B<-n>
List only non-existing files.
=item B<-p> I<pid>
Trace process id.
=item B<-u>
List only files once.
=back
=head1 EXAMPLES
=head2 EXAMPLE: Find the missing package
Assume you have a program B<foo>. When it runs it fails with: I<foo:
error: missing library>. It does not say with file is missing, but you
have a hunch that you just need to install a package - you just do not
know which one.
tracefile -n -u foo | apt-file -f search -
Here B<ls> tries to find B</usr/include/shisa.h>. If it fails,
B<apt-file> will search for which package it is in:
tracefile -n -u ls /usr/include/shisa.h | apt-file -f search -
=head1 REPORTING BUGS
Report bugs to <tange@gnu.org>.
=head1 AUTHOR
Copyright (C) 2012 Ole Tange, http://ole.tange.dk and Free
Software Foundation, Inc.
=head1 LICENSE
Copyright (C) 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head2 Documentation license I
Permission is granted to copy, distribute and/or modify this documentation
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the file fdl.txt.
=head2 Documentation license II
You are free:
=over 9
=item B<to Share>
to copy, distribute and transmit the work
=item B<to Remix>
to adapt the work
=back
Under the following conditions:
=over 9
=item B<Attribution>
You must attribute the work in the manner specified by the author or
licensor (but not in any way that suggests that they endorse you or
your use of the work).
=item B<Share Alike>
If you alter, transform, or build upon this work, you may distribute
the resulting work only under the same, similar or a compatible
license.
=back
With the understanding that:
=over 9
=item B<Waiver>
Any of the above conditions can be waived if you get permission from
the copyright holder.
=item B<Public Domain>
Where the work or any of its elements is in the public domain under
applicable law, that status is in no way affected by the license.
=item B<Other Rights>
In no way are any of the following rights affected by the license:
=over 2
=item *
Your fair dealing or fair use rights, or other applicable
copyright exceptions and limitations;
=item *
The author's moral rights;
=item *
Rights other persons may have either in the work itself or in
how the work is used, such as publicity or privacy rights.
=back
=back
=over 9
=item B<Notice>
For any reuse or distribution, you must make clear to others the
license terms of this work.
=back
A copy of the full license is included in the file as cc-by-sa.txt.