1832995 Members
2380 Online
110048 Solutions
New Discussion

tar not working

 
Anand_30
Regular Advisor

tar not working

Hi,

I have ftped one tar file from one machine to another using binary mode. But when I tried to untar the file in the destination machine, I got the message:

tar: cannot open file

Can anyone tell me what is the reason for this message.

Thanks,
Andy
13 REPLIES 13
Patrick Wallek
Honored Contributor

Re: tar not working

What command did you use? Where is the file located? What are the permissions on the file?

The error indicates that tar either doesn't have permissions to open the file or can not see the file.
Sunil Sharma_1
Honored Contributor

Re: tar not working

Hi,


Is it working on source machine.

try ftp again.

tar -xvf

Sunil
*** Dream as if you'll live forever. Live as if you'll die today ***
Elmar P. Kolkman
Honored Contributor

Re: tar not working

Also try tar tvf on both machines. This will print out the names of the files contained in the tar file, and thus verify the tar file.
If that does work, your problem is probably that the file inside the tar file can not be created on your system...
If that doesn't work on the destination machine, but works on the source machine, the problem is with the FTP.
If it doesn't work on both machines, check what you wanted to tar. I am not sure what message tar gives if you tried to tar files over 2 Gb... tar's limit.
Every problem has at least one solution. Only some solutions are harder to find.
Steven E. Protter
Exalted Contributor

Re: tar not working

Permissions: If the untar user can't write to the location the file is sitting this will give you an error, though in my experience you will get a slightly more meaningful error.

I just ran a test as a non-root user on a tar file owned by root in a directory the user did not have write permissions on. The error messag involved can not create warnings, so I don't think its straight permissions.

Based on this test, I would surmise that the ftp tranfser was incomplete or ...

Perhaps the tar file is bigger than 2 GB and the target filesystem isn't set for largefiles.

You are using tar xvf , right?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
H.Merijn Brand (procura
Honored Contributor

Re: tar not working

And did you use the same 'tar' on both systems? GNU tar will read almost any tar format, but HP tar might have trouble with reading GNU tar

More likely is a kind of umask being applied during the copy. Check the file's mode, or just

# chmod 644 file.tar
# tar tvf file.tar

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Steven E. Protter
Exalted Contributor

Re: tar not working

I just ran an addition test.

as root owner chmod 700 tarfile

su - user

tar xvf tarfile

Got your exact message. Its permissions.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Elmar P. Kolkman
Honored Contributor

Re: tar not working

You didn't put the tar file on a NFS mounted filesystem by any chance? Because in most cases they are mapping root to anonymous for security reasons, which would explain the security message...
Every problem has at least one solution. Only some solutions are harder to find.
Michael Schulte zur Sur
Honored Contributor

Re: tar not working

Hi Andy,

it can only be a matter of permission, otherwise tar would complain, that this is no tar archive or has found a checksum error or so. Be sure to rule out disk/file system errors.

greetings,

Michael
Fabio Ettore
Honored Contributor

Re: tar not working

Hi Andy,

just a doubt:

"tar: cannot open file"

is it exactly error message? Or

"tar: cannot open "

In the first case it is very strange, I saw it only when there are hardware problem.
In the second case it is a permission problem as specified perfectly by SEP and others.

Best regards,
Ettore
WISH? IMPROVEMENT!
Keith Bevan_1
Trusted Contributor

Re: tar not working

Andy,

Permissions on the directory where you are trying to untar the file !

Do you have write permission to the directory.

Keith
You are either part of the solution or part of the problem
Anand_30
Regular Advisor

Re: tar not working

Hi All,

Thanks for the reply. I changed the owner of the tar file and now it has started working fine.

Thanks,
Andy

Michael Schulte zur Sur
Honored Contributor

Re: tar not working

Hi,

if the problem is solved, could you spare some points from the endless supply of points, HP has, for those, who could help you? ;-)

greetings,

Michael
KapilRaj
Honored Contributor

Re: tar not working

Why ftp ??? wanna extract a file from node1 to node2 location ?

On node1

cd ;tar cvf - . |rsh node2 "(cd DIR_TO_RESTORE>;tar xvf -)"

Kaps ...
Nothing is impossible