Operating System - HP-UX
1825719 Members
2950 Online
109686 Solutions
New Discussion

Redirecting the output of fbackup

 
SOLVED
Go to solution
Alex Montanez
Occasional Contributor

Redirecting the output of fbackup

Hi,
I'm trying to redirect the output of an fbackup command to a file so I can then e-mail the result of the backup.
I have tried:
fbackup -g gfile -f /dev/rmt/0m > backup.txt
this does the backup I need but the resulting backup.txt file does not contain any information, it's length is zero, and I can also see the results in the screen. I have tried different variations, but the results remain the same:
fbackup -g gfile -f /dev/rmt/om >> backup.txt
fbackup -g gfile -f /dev/rmt/0m 1>backup.txt
I also tried creating a shell script with the fbackup command and redirecting the output to a file:
backup.sh > backup.txt
Also tried using the tee command, but nothing seems to work.
Can somebody help me?

Thanks,
Alex Montanez
8 REPLIES 8
Bruce Regittko_1
Esteemed Contributor

Re: Redirecting the output of fbackup

Hi,

The output is probably going to standard error instead of standard output. Try using 2> instead of >.

To make sure you get both stdout and stderr, use the following: cmd 2>&1 > file.out

This will place cmd's stderr on the stdout channel and then redirect cmd's stdout (with stderr) to file.out.

--Bruce
www.stratech.com/training
federico_3
Honored Contributor

Re: Redirecting the output of fbackup

In order to redirect the output , you should use the following expression:

fbackup -g gfile -f /dev/rmt/0m 1> backup.txt

I hope this helps
Federico
Dan Hetzel
Honored Contributor
Solution

Re: Redirecting the output of fbackup

Hi Alex,

Make sure the 'stderr' is redirected as well like in:

fbackup -g gfile -f /dev/rmt/0m > backup.txt 2>&1

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
James R. Ferguson
Acclaimed Contributor

Re: Redirecting the output of fbackup

Hi:

You might also want to add the '-v' option to your fbackup. Redirect both stdout and stderr to a file and you will have a complete record and tape directory of your backup. If you choose the verbose logging, you will undoubtly want to mail yourself only the success or failure notice, however.

...JRF...
Alex Montanez
Occasional Contributor

Re: Redirecting the output of fbackup

Hi,
Thanks for everybody that responded, I tried all the solutions posted, but only Dan Hetzel solution worked, I'm trying to figure out why that solution did work and not the others.

Thanks,
Alex Montanez
Dan Hetzel
Honored Contributor

Re: Redirecting the output of fbackup

Hi Alex,

A few explanations:
Bruce's solution doesn't work because he is redirecting 'stderr' to be the same as 'stdout' (to the tty, where it defaults) and redirects 'stdout' thereafter.

Frederico didn't redirect 'stderr'

James' explanation is perfectly right, although he didn't give you an example to redirect both stdout and stderr to the same file.

When redirecting both file descriptors to the same file, keep in mind that you have to redirect stdout first and stderr after, that's why the '2>&1' is last.

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Bruce Regittko_1
Esteemed Contributor

Re: Redirecting the output of fbackup

Hi again,

Thanks Dan! I usually get the redirections backwards even though I know better. Makes me almost want to resort to

cmd >> file.out 2>> file.out

--Bruce :)
www.stratech.com/training
Sy-Hoang Truong
Occasional Contributor

Re: Redirecting the output of fbackup

Please try with :

/usr/sbin/fbackup -0 -f /dev/rmt/0m -i/data -I /tmp/index

Index is the file you can print out or attached with your email.