Operating System - HP-UX
1849813 Members
3923 Online
104044 Solutions
New Discussion

Re: frecover in a script ..

 
SOLVED
Go to solution
Sally  Devine
Frequent Advisor

frecover in a script ..

Hello all,

I have a little script to write the contents of a tape to an output file.

/usr/sbin/frecover -xNv -f /dev/rmt/0m 2>/tmp/listing

I can run this command without a problem from command line. However, when I try and run it from a script I get "unable to find device file /dev/rmt/0m"

Any ideas?

Thank you all very much,
Sally
15 REPLIES 15
Jeff Machols
Esteemed Contributor

Re: frecover in a script ..

Try to do a rewind before calling the frecover

mt -t /dev/rmt/0m rewind
Alan Casey
Trusted Contributor

Re: frecover in a script ..

You must run this script as root, or in root's cron.

How are you running the script?
Christopher McCray_1
Honored Contributor

Re: frecover in a script ..

I am really taking a risk here.... Is it a O or a 0 in your script??? (sorry in advance if dumb response)

Chris
It wasn't me!!!!
A. Clay Stephenson
Acclaimed Contributor

Re: frecover in a script ..

I am guessing that this command follows another that is accessing the drive. You are probably not allowing enough time between commands. One easy answer is to add a sleep to your script.

If it ain't broke, I can fix that.
Jeff Machols
Esteemed Contributor

Re: frecover in a script ..

Thats a good point Chris (checking those things is never a bad idead). In Fact you might want to cut the line right out of the script to make sure there is nothing else different. Also, are you running the shebang in your script.

#!/bin/ksh

or whatever shell you are using
Sally  Devine
Frequent Advisor

Re: frecover in a script ..

In response to all the above questions:

1. I tried the mt -t dev rewind and it did not work

2. I am not doing anything else beforehand with the device - so it is not busy

3. I definitely have /dev/rmt/0m (I always check for typos first)

Basically, I run the script and get the error. I go to the command line and type exactly what I have in the script and it runs fine.

Thanks for all the quick responses,
Sally
Sally  Devine
Frequent Advisor

Re: frecover in a script ..

I also wanted to mention that I have other scripts that run frecover - but they are actually restoring data and they work fine. It is just trying to get a tape listing that is giving me the headache.
Jeff Machols
Esteemed Contributor

Re: frecover in a script ..

Sally,

you might want to do an fuser on the device file in the script (just to see) and make it doesn't show anything. Also, have to tried a different device file, like /dev/rmt/0mn
Jeff Machols
Esteemed Contributor

Re: frecover in a script ..

Sally,

One more thing. run the env command on the command line and from your script. See of there any differences, it is possible that LANG or some other environment variable is getting changed and not allowing to you access the device file properly.
Sally  Devine
Frequent Advisor

Re: frecover in a script ..

Jeff,

fuser didn't show anything and the env was the same. Also, I tried /dev/rmt/0mn and it didn't work either.

The error message that comes up is that the device is not found - then goes on to say unable to use the device, etc.
Jeff Machols
Esteemed Contributor

Re: frecover in a script ..

ok, lets try this. Change the frecover command to:

tar -tvf /dev/rmt/0m

Run the script and check the error. If the error says Checksum, or blocksize error the problem is in the frecover, it you get can't open file /dev/rmt/0m then there is an issue in script. Then we can troubleshoot from there
Sally  Devine
Frequent Advisor

Re: frecover in a script ..

Ok Jeff,

Ran your request and got the checksum error. So I guess the problem is with frecover. But as mentioned before, frecover runs perfectly if I am restoring something...I only run into this problem when I just want a tape listing. Again, I am running:

frecover -xNv -f /dev/rmt/0m

Thanks again,
Sally
Jeff Machols
Esteemed Contributor
Solution

Re: frecover in a script ..

Sally,

couple more things to try. First, put a -y in the options. This way if there are any questions asked you won't messed up waiting for a prompt when you output is going to a file. Also, You may want to leave out the -f dev part. /dev/rmt/0m is the default if nothing is specified, I wounldn't know why that would help, but it would be interesting to see what happened.
Sally  Devine
Frequent Advisor

Re: frecover in a script ..

Thanks Jeff, that worked! So when you use frecover to do a listing leave off the -f /dev/rmt/0m...I guess if it worked then that is good enough for me, but it makes no sense considering the other scripts work using the -f switch.

Thanks again,
Sally
Bill Hassell
Honored Contributor

Re: frecover in a script ..

If all you want is a listing of the files on the tape, there is a much easier (and 100x faster) way to do this:

/usr/bin/frecover -I /tmp/listing -f /dev/rmt/0m

Unlike legacy tools like tar and cpio, all the files that were selected at the start of the backup will be listed. The -xNv options will require reading (and computing extra checksums) for the whole tape...possible hours. The -I option can be completed in a couple of minutes.


Bill Hassell, sysadmin