SUMMARY:cp and rm log question

From: Michel Pilon (pilonm@CCG.RNCan.gc.ca)
Date: Fri Oct 17 1997 - 09:41:18 CDT


Hello Sun gurus,

Sorry to be so late about this summary but here it is !

I have received many posts about my following original post :

> ==========================================================================
>
> I would like to get a trace of each deleted files when I use "rm" (like a
> log file). Same thing when I use "cp". There are no "rm -e" on Solaris.
> For those who are familiar with VMS, COPY/LOG and DELETE/LOG does
> the thing I want.
>
> Any ideas???
>
> Thank you very much in advance,
>
> --
> Michel Pilon E-mail: michel.pilon@CCG.RNCan.gc.ca
> Administrateur de systemes Unix Tel: (819) 564-4819
> Centre d'information topographique Fax: (819) 564-5698
> 2144 King Ouest, suite 010, Sherbrooke, Quebec, Canada, J1J 2E8
> http://cyniska.ubishops.ca/pilonm
>
> ==========================================================================

First, let me explain the situation a bit. My name is Dominic Langlois. I am an
almost newbie unix programmer who is currently writing a kind of wrapper to
sccs. I need to keep a trace of the files who are moving around between sources
and the development sites. The VMS system mostly offers to /log option to get a
trace of what is going on. So, Michel posts for me the question to the list as
I did not subscribed.

** Now, about the summary !!!

Initialy, the cp and rm commands do not log their actions. So, most of the
posts suggest me to create some kind of alias or wrapper either in shell
script or in some langages such C or Perl (examples following). Doing so, I
have to take care about being very wasteful. I should also build a kind of
error reporting.

Some other posts suggest me to get at some existing GNU and MIT packages.

** My approach !!!

As some persons point me to Perl, I have read more carefully the Perl doc
about modules and found something about the File::Find and File::CheckTree
modules. Those modules are explained in the Camel book (Programming Perl),
2nd Edition, p. 438-439. I have also found a very interesting example in the
Llama book (Learning Perl), p. 146. This shows us than we should always look
at the examples. Shame on me !

By the way, I have learned about the script and logger commands on unix machine
(thanks to Mark Hargrave and Matthew Lee Stier).

** Here are some alias and script examples :

1- Shell script rm_log :
      echo $* >>$HOME/.rm_log
      /usr/bin/rm $*

2- C shell script :
     #!/bin/csh
     echo $* >> /var/adm/log_rm
     /bin/rm -i $*

3- Alias rm :
     alias rm 'echo \!* >> /tmp/log && /bin/rm \!*' ( very interesting ! )

4- Shell script :
     #!/bin/sh
     # logrm - log name of file removed in /tmp/rm-files, then remove the file
     #
     if [ -f $1 ] ; then
        echo "rm $1" >> /tmp/rm-files ; /usr/bin/rm $1
     else
        echo "File not found."
     fi

5- C shell script :
     #!/bin/csh
     echo Copy ran on `date` >> /var/log/cp.log
     cp $1 $2

6- Shell script :
     rm_l() {
     for afile in "$@" ; do
         rm "$afile"
         echo "$afile: deleted"
     done
     }

7- Llama book example (perl)
     foreach $file (<*.o>) { # step through a list of .o files
         unlink ($file) || print "Having trouble deleting $file\n";

** AND NOW, THE GREETINGS !!!

Many thanks to all of you who answered to my question :

Merci à tous ceux et celles qui ont pris le temps de vouloir m'aider :

Richard Casto, radical consulting, inc. / rich@rcon.com
Mark Hargrave, Lockheed Martin Michoud Space Systems /
hargrme@wisdom.maf.nasa.gov
Normand Ranger, CIRANO /
rangern@cirano.umontreal.ca
Kes Masalaitis, BNP / Cooper Neff / kes@mop.com
Randy Banks, ESRC Research Centre on Micro-Social Change / randy@essex.ac.uk
Aline Runde, MicroModule Systems, Inc. / arunde@mms.com
Karl Vogel, ASC/YCOA /
vogelke@c17mis.region2.wpafb.af.mil
David Wolfskill, / david@xtend.net
Philip A. Fitzpatrick, University of Georgia /
phil@philco.libs.uga.edu
Matthew Lee Stier, Fujitsu Network Communications /
Matthew.Stier@tddny.fujitsu.com
David Thorburn-Gundlach, /
dtg@cae091.ed.ray.com,david@bae.uga.edu
Nick, / Nicky@neta.com
Ray Trzaska, / rtrzaska@uk.mdis.com
Michael Hill, Aerospace/Software Engineer / Hill.Michael@tci.com
Scott Steverson, Comdata Corporation / scoste@comdata.com



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:05 CDT