in reply to Tar GZip Question

That's two tasks: downloading and extracting. Perl modules that address those are LWP for downloading and Archive::Tar for extraction. You might also use system to call wget or curl for downloading and tar for extraction - see man wget and man tar. Or use a mix of both, if necessary/desired.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Tar GZip Question
by Anonymous Monk on Oct 30, 2002 at 03:06 UTC
    I tried to do that. The problem is getting it to extract intp a different directory. I tried this:
    mirror("http://www.digitmania.holowww.com/targz/katt0$number.tar.gz", + "katt0$number.tar.gz"); system("mv", "katt0$number\.tar\.gz", "\.\.\/html\/img\/katt0$number\ +.tar\.gz"); system("tar", "zxvf", "\.\.\/html\/img\/katt0$number\.tar\.gz");
    It downloads and moves the files, but won't extract them in that directory. Do you know what might be wrong (or have an alternative solution)?
      man tar has what you need:
      -C, --directory DIR change to directory DIR
      You needn't move the file either, it's enough to pass that parameter. Otherwise, tar will of course work in the current directory.

      Makeshifts last the longest.

      My psychic powers tell me you are doing this through CGI and the anonymous user "httpd" or "nobody" or "iusr_xxx" does not have permission to write to the directory in question.

      Second, what's with all the backslashes? Yech!

      Third, You should use the rename function within perl (or the File::Copy module) to do your moving, not an external command.

      Fourth, you should use Archive::Tar to handle your extraction, not an external command.

      Fifth, whether you use modules or external commands to do your file handling and extraction, you should always, *always*, ALWAYS return the error message from the operation ($! for perl system functions, $? for system commands.

      --
      Regards,
      Helgi Briem
      helgi AT decode DOT is