gzip untar in specific directory /temporary

gzip untar in specific directory /temporary

Post by Feisal Gaffa » Sat, 06 Dec 2003 01:46:04



Hi Folks,

Maybe someone can help me.
I have problem when I try gzipping and untarring a file.

When I do that tar will unzip the files in de directory that it originally
By doing this I sometimes e*ntly overwrite somefiles. This is very
frustrating.
What I would like to do in put the file in a specific directory.

I have viewed the man pages of tar and could not find a signal way to
accomplish that.

This is the command I use;
gzip -dc filename.tar.gz | tar xvof -

This will try to unzip the file in :

/opt/InfoVista/
what I want to do is put the file in directory /temporary instead of
/opt/InfoVista

Is  there a possible solution or workaround for this.

Thanks
gr.
Feisal

 
 
 

gzip untar in specific directory /temporary

Post by Kevin Rodger » Sat, 06 Dec 2003 02:30:44



> Hi Folks,

> Maybe someone can help me.
> I have problem when I try gzipping and untarring a file.

> When I do that tar will unzip the files in de directory that it originally
> By doing this I sometimes e*ntly overwrite somefiles. This is very
> frustrating.
> What I would like to do in put the file in a specific directory.

> I have viewed the man pages of tar and could not find a signal way to
> accomplish that.

> This is the command I use;
> gzip -dc filename.tar.gz | tar xvof -

> This will try to unzip the file in :

> /opt/InfoVista/
> what I want to do is put the file in directory /temporary instead of
> /opt/InfoVista

> Is  there a possible solution or workaround for this.

It depends.  If the tar file contains absolute paths (file names that
all begin with /), then no.  If the tar file contains relative paths
(file names that don't begin with /), then just cd to /temporary before
you run the gzip | tar command.

--
Kevin Rodgers

 
 
 

gzip untar in specific directory /temporary

Post by Bill Marcu » Sat, 06 Dec 2003 06:56:26


On Thu, 04 Dec 2003 16:46:04 GMT, Feisal Gaffar

> Hi Folks,

> Maybe someone can help me.
> I have problem when I try gzipping and untarring a file.

> When I do that tar will unzip the files in de directory that it originally
> By doing this I sometimes e*ntly overwrite somefiles. This is very
> frustrating.
> What I would like to do in put the file in a specific directory.

> I have viewed the man pages of tar and could not find a signal way to
> accomplish that.

> This is the command I use;
> gzip -dc filename.tar.gz | tar xvof -

> This will try to unzip the file in :

> /opt/InfoVista/
> what I want to do is put the file in directory /temporary instead of
> /opt/InfoVista

> Is  there a possible solution or workaround for this.

If you have gzip and gunzip, you may have a copy of GNU tar somewhere,
perhaps named gtar or /usr/local/bin/tar.  GNU tar ignores absolute
pathnames, and it can extract gzipped archives with a single command:
tar xvozf filename.tar.gz

--
Thanks to Nigeria, any email with the word "urgent" in the subject
or address will be deleted.

 
 
 

gzip untar in specific directory /temporary

Post by Adam Pric » Sun, 07 Dec 2003 18:25:33




Quote:> Hi Folks,

> Maybe someone can help me.
> I have problem when I try gzipping and untarring a file.

> When I do that tar will unzip the files in de directory that it
> originally By doing this I sometimes e*ntly overwrite
> somefiles. This is very frustrating.
> What I would like to do in put the file in a specific directory.

> I have viewed the man pages of tar and could not find a signal
> way to accomplish that.

> This is the command I use;
> gzip -dc filename.tar.gz | tar xvof -

> This will try to unzip the file in :

> /opt/InfoVista/
> what I want to do is put the file in directory /temporary instead
> of /opt/InfoVista

> Is  there a possible solution or workaround for this.

> Thanks
> gr.
> Feisal

Gnu tar will strip the leading / automaticaly, so if that is what
you have then just make a temporary directory, cd there and extract.

If instead you don't have gnu tar then the 'pax' command should be
on most posix systems and is capable of reading tar archives.
It's man page will tell you how to substitute /temporary
for /opt/InfoVista.

In either case, never unpack an archive without listing the contents
first, otherwise as you have found you run the risk of overwriting files.
Adam

 
 
 

gzip untar in specific directory /temporary

Post by Michael Pao » Mon, 08 Dec 2003 13:14:35



Quote:> I have problem when I try gzipping and untarring a file.
> When I do that tar will unzip the files in de directory that it originally
> By doing this I sometimes e*ntly overwrite somefiles. This is very
> frustrating.
> What I would like to do in put the file in a specific directory.
> I have viewed the man pages of tar and could not find a signal way to
> accomplish that.
> This is the command I use;
> gzip -dc filename.tar.gz | tar xvof -
> This will try to unzip the file in :
> /opt/InfoVista/
> what I want to do is put the file in directory /temporary instead of

Well, a few points, "Best Practices", etc.

It's generally advisable to inspect the contents (at least pathnames) of
the contents of a tar archive before extracting the contents.  This
is critical if contents haven't been verified and/or if an ID of any
privilege is used to extract the tar archive.

The tar program restores items to the pathnames stored in the archive.
Best Practice is to always use relative pathnames (pathnames not
starting with /) when creating tar archives.  Similarly, it's also Best
Practice to never use .. directory in creating a tar archive.  If tar
archive was created with relative pathnames, having the current working
directory of tar be a suitable directory when extracting from the tar
archive, is usually sufficient to avoid placing extracted contents
anywhere particularly unexpected or dangerous (presuming one has
reviewed the pathnames stored in the archive).  E.g.:
$ gzip -d < foo.tar.gz | (cd /temporary && tar -xf -)

If the tar archive contains absolute pathnames (pathnames starting with
/) some versions of tar (e.g. GNU tar) can suppress the absolute
pathname.

If one needs to restore from tar archive that contains
absolute pathnames, and one doesn't have access to a version of tar that
can be used to suppress absolute pathnames, but one does have superuser
access available, chroot can be used to restore relative to a
chroot root, rather than the actual system root.  Note however that such
an approach can be potentially non-trivial, as all the requisite
components necessary to do the restore need to be present in the chroot
environment.  This might still be problematic if there are
conflicts between absolute pathnames in the archive and requisite
components necessary to do the restore.

 
 
 

1. Creating a temporary file in a specific directory?

Is there any easy way to create a temporary file in a specific (but random
from time to time( directory?

I needed to modify some files and rather than creating a temp-file in /tmp,
writing it's contents, then closing and copying it back to the original
file, I decided to create a temp-file in the same directory as the
input/output file. The code works (but may not always do so because the
find-a-name algorithm isn't very robust) but it's not pretty.  Is there some
library function call that I missed?

Thanks
    Norm

2. Install Redhat V4.0 from CD or Hard disk

3. Specific files in a specific directory?

4. Special ls -l

5. To use temporary files or not to use temporary files?

6. i need help w/ linux

7. root directory for installing (untar & gunzip)?

8. USRobotics Attached to 16-port RAN

9. How to untar all tar files in a directory

10. Which directory to untar the applications to????

11. Untar to a different directory

12. netscape what directory to untar from

13. patchadd, temporary directory