1834414 Members
1569 Online
110067 Solutions
New Discussion

about tar command!

 
SOLVED
Go to solution
leyearn
Regular Advisor

about tar command!

when i execute #tar cv /etc/hosts command
the content of hosts is printed on console
i must #tar cvf /dev/rmt/0m /etc/hosts
why
is there something wrong with my tape drive or configuration ?
9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: about tar command!

I almost never use the 'tar -cv filename' form of tar. I always specify the '-f destination' option because I want to know EXACTLY where I am tarring to.

Apparently you /dev/rmt/0m is not set as the default destination for tar so you are just getting output sent to stdout which is your terminal. I am really not sure where that is set, but I wouldn't worry about it too much. Just explicitly specify your destination and you can be fairly certain that it will work 100% of the time.
leyearn
Regular Advisor

Re: about tar command!

where can i change the configuration ?
Naveej.K.A
Honored Contributor

Re: about tar command!

hi,

"f" in tar tvf specifies the device file name. and the default archive file for tar is /dev/rmt/0m. There could not be any problem with your tape drive.

see man tar for details

regds
Naveej
practice makes a man perfect!!!
Steven E. Protter
Exalted Contributor

Re: about tar command!

On most systems tar defaults to the /dev/rmt/0m tape drive.

Going to the console is unique.

Like patrick says use the -f parameter and controll it.

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
Shaikh Imran
Honored Contributor

Re: about tar command!

Hi,
Use insf -e and then try for your command If it does'nt work then better use tar -cvf /dev/rmt/0m .
Or create a script and user tar -cvf in it.

Regards,

I'll sleep when i am dead.
Trond Haugen
Honored Contributor
Solution

Re: about tar command!

This is rather odd. The destination for tar has defaulted to /dev/rmt/0m at least since HP-UX 3.1/5.2. Which version of HP-UX are you running?
Also you could check which tar you are running with 'which tar'.. The run a what on that tar.. In one command you could run 'what $(which tar)'.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
leyearn
Regular Advisor

Re: about tar command!

nvl2:/> uname -a
HP-UX nvl2 B.11.00 A 9000/861 2003908693 two-user license
nvl1:/> which tar
/usr/local/bin/tar
nvl1:/> echo $PATH
/usr/sbin:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/sbin:/etc:/
opt/nettladm/bin:/opt/fc/bin:/opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/con
trib/bin/X11:/usr/bin/X11:/opt/hparray/bin:/opt/ignite/bin:/opt/resmon/bin:/usr/
sbin/diag/contrib:/opt/pred/bin:/sbin:/home/root


now i know i am using the /usr/local/bin/tar
is there difference among /usr/bin/tar , /sbin/tar and /usr/local/bin/tar

how can i change the PATH enviroment variable to move /usr/bin to be before /usr/local/bin?
Trond Haugen
Honored Contributor

Re: about tar command!

I believe you have found the root cause.
Yes, there is a difference between /usr/bin/tar, /sbin/tar and /usr/local/bin/tar. The first two are standard HP-UX and differ "only" in linking:
/usr/bin/tar: PA-RISC1.1 shared executable dynamically linked
/sbin/tar: PA-RISC1.1 shared executable
The latter "could be anything". And definitely seem to have stdout as default device.

As for the order of patche in PATH all you have to do is change the order. But where to do that depends on where it is set. It could be the default path - check /etc/PATH or it could be set in /etc/profile or $HOME/.profile. I would reccomed putting /usr/local/bin and /usr/contrib/bin at the end as they mau contain commands with the same name as "system commands". As is the case with tar.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Patrick Wallek
Honored Contributor

Re: about tar command!

I would guess that the /usr/local/bin/tar is probably the GNU Version of tar. That is definitely NOT the standard HP-UX version of tar.

I have GNU tar installed on a couple of my machines and I just tried doing:

# /opt/tar/bin/tar -cv /etc/hosts

and the output printed to my terminal. I would say that this is probably normal for GNU tar.

If you don't want this behavior, then just specify the '-f destination' option. Yes, it's a few more keystrokes. So what!

As I said above, I much prefer knowing exactly where my output is going thus I always use '-f destination' in my tar commands.