Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: command to tar files
by davorg (Chancellor) on Jan 17, 2001 at 15:58 UTC

    Not really sure a) what this has to do with Perl or b) why you'd want to tar up one file, but here's the command.

    tar xf /path/to/output/file /path/to/input/file

    Typing man path would be a faster way to get this information.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

      It is important to remember that when you tar in this way /path/to/input/file is stored in the tar so when you extract it, it will put it back in that very location. You probs what to ensure that you execute the tar command from the root of the files you want to tar and specify a full pathname to the tar file you are creating rather than the other way around.
      --

      Zigster
Re: command to tar files
by hannibal (Scribe) on Jan 18, 2001 at 03:28 UTC
    For a Perlish method of archiving, check out Archive::Tar (and probably Compress::Zlib which I think Archive::Tar has hooks for) on CPAN.
Re: command to tar files
by MadraghRua (Vicar) on Jan 18, 2001 at 05:38 UTC
    You could have a look in the PerlCookbook, pages 555 - 557. Otherwise you might try this:
    #!/usr/local/bin/perl -w my $tarPath = "/path/to/place/tar/file"; my $fileName = "/path/to/file"; my $command = "tar xvf "; $message = system ($command $tarPath $fileName); if ($message == 0) { print "All done!\n"; } else { print "Whoops! $command gave exit error: $?\n"; }

    MadraghRua
    yet another biologist hacking perl.... ---------------------------------------------------- UPDATE
    You might want to stick a my in front of $message to satisfy the -w switch - sorry!