Ask the Expert

Batch processing cpio -r

We have a Unix database that completes a cold backup to tape every night. The files are written out using their full pathname using the cpio command. We need to restore these files to a different pathname for creating test database purposes. I have looked at the cpio -r option but this seems to only be available in interactive mode. We need a way of batch processing this cpio -r for multiple datafiles... any advice and/or scripts would be appreciated.

    Requires Free Membership to View

There are a couple of options for you. One option is to use a scripting language called Expect. Expect is a scripting language that can interface with any command line interface. You tell Expect what to "expect", and your Expect script will supply the next answer. For instance, you can invoke SQL*Plus from Expect. You tell Expect to expect the prompt for the username. Then, when Expect sees this prompt, it passes the supplied username to the SQL*Plus executable. You can use it to do the same thing in your example. Have your Expect script call "cpio -r" for you. Tell it what to expect in return and how to respond to that prompt. Expect is one of the great scripting languages that no one talks about!

Otherwise, you might want to consider dropping the directory path from your files that you archive with cpio. Or consider using something other than cpio to do the archive.

For More Information


This was first published in January 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: