in reply to scripting tar

You can run it thru system or backticks, but the syntax for options can get tricky. For instance
system ('tar','-c','-XEXCLUDE_FILE','-M','-L50000',"-F ./backup-rotate +.pl $basename","-f$basename-0.tar",$dir);

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: scripting tar
by slacker (Friar) on Jan 30, 2009 at 21:42 UTC
    Is there a specific reason why you would have to use perl for this? This could easily be written in a shell (bash,csh, etc) script.
      Is there a specific reason why you would have to use perl for this

      Well, that line was pulled from a more complex script, that is far easier to do in Perl, than something like bash shell. For instance, what if you were automating writing the tarballs to a cd/dvd, or transferring it over a socket to another location, forking the work off, etc. Additionally, file and directory operations are soooo much easier with Perl, than shell, especially if you are used to Perl and abhor shell syntax.

      So....it is often better to use Perl , and run the occaisional command thru system/backtick/pipe, and have the full power of Perl available when needed for things shell dosn't do well.


      I'm not really a human, but I play one on earth Remember How Lucky You Are
        My intention is not to hijack the above thread but.... Would you mind providing an example where using Perl is easier to manipulate files and directories as opposed to using a shell? Unless i'm misunderstanding, I would almost always prefer to use mkdir,chmod, chown, cat or whatever platform you're using, over using Perl to do the same thing. Thanks.
        That's exactly why I need Perl instead of shell scripting. It has to by highly dynamic and automated taking information from a config file for the files to tar.