in reply to Simple Backup Script

Any reason why this must be done in Perl? A simple shell script should do the job quite nicely.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Simple Backup Script
by Anonymous Monk on May 07, 2003 at 15:51 UTC
    No reason i guess, i have never wrote a shell script before tho :(

      While there are some complex things you could do with it, for this problem, you shouldn't need much more than writing out the same commands you would give on a command line, plus a few variables.

      #!/bin/sh date=`date +%Y%m%d%k%M%S` path=$1 # Path to use is given on the command line # Use last directory in ${path} as the filename to save # to. (Could use awk or something else here, but I'm # more familer with Perl). # save_file=`perl -e '$file=pop; $file=~m!/(.*)$!; print $1' ${path}` tar -zxf ${save_file}-${date}.tar.gz ${path}

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      Note: All code is untested, unless otherwise stated