1753699 Members
4860 Online
108799 Solutions
New Discussion юеВ

fbackup return value

 
Koh Kuan Wong
Occasional Contributor

fbackup return value

I am using the system variable ($?) to capture the return value of a fbackup.
If it returns a 0, then I know that the backup was successful. What if it returns a different value? For example $? = 1024. I would like to know what does it stand for.

Is there a reference table where I can view all the different values to see what does it stands for?
8 REPLIES 8
vtpaulson
Frequent Advisor

Re: fbackup return value

Hi,

fbackup returns 0 upon normal completion, 1 if it is interrupted but allowed to save its state for possible restart, and 2 if any error conditions prevent the session from completing.

There is no other return value available in fbackup.

Regards,
Paulson
Bill McNAMARA_1
Honored Contributor

Re: fbackup return value

For all RETURNS see the man page of the command.

ie man fbackup and search (/) for RETURNS to get a description of all possible returns and their meaning.

Later,
Bill
It works for me (tm)
Magdi KAMAL
Respected Contributor

Re: fbackup return value

Hi,

The fbackup return codes are :

0 : upon normal completion.
1 : If it is interrupted but allowed to save its state for possible restart.
2 : If any error conditions prevent the session from completing.
4 : If any warning conditions are encountered.

This for error code and for the text explaining what had happend :

IT WILL BE WRITTEN TO THE SERVER'S CONSOLE.

HTH.

Magdi

Gregory Fruth
Esteemed Contributor

Re: fbackup return value

fbackup normally returns 0, 1, 2 or 4 as per the man page.
Perhaps you're calling fbackup from a C program or
Perl script via system() or a fork()/exec()/wait(). In this
case, the return value is encoded per the wait(2) man
page, so you need use WEXITSTATUS to find out what
the real exit status is. A 1024 probably means that
the return code was actually 4 (1024 >> 8).

HTH
James R. Ferguson
Acclaimed Contributor

Re: fbackup return value

Hi:

You can see a list 'fbackup's error codes by number and associated text here:

# strings /usr/lib/nls/C/fbackup.cat

...JRF...
Koh Kuan Wong
Occasional Contributor

Re: fbackup return value

thanks for all the feedback so far.

sorry for not explaining in more detail.
I am calling the fbackup function inside a Perl script using system(). For example:
system("/usr/sbin/fbackup -v -f /dev/rmt/1m -i /");
if ($? == 0) {
print "Backup successful!";
}
else {
print "Error code = $?";
}

Gregory,
Can you please explain a bit more in detail about WEXITSTATUS. How did you derive a 1024 to be a return code of 4?

Thanks again.

Kuan Wong
Vincent Stedema
Esteemed Contributor

Re: fbackup return value

Hi,

You might also want to examine the contents of the perl ERRNO variable $!, which should contain the error returned by the system call. In your case:

system("/usr/sbin/fbackup -v -f /dev/rmt/1m -i /") || die "ERROR: $!\n";

HTH.

Regards,

Vincent
Gregory Fruth
Esteemed Contributor

Re: fbackup return value

See the description of Perl's system() call and the
$? variable for more info. It'll tell you to divide the
return value by 256 or right shift it by 8 bits to get
the actual return value from the called program.
So (1024 / 256) = (1024 >> 8) = 4.

To be more precise, use Perl's POSIX module
to get acess to the WEXITSTATUS and associated
macros, which can be used to decode all parts of
system()'s return value. See the docs for Perl's POSIX
module and the HP-UX man page for wait(2) (i.e.
"man POSIX" and "man 2 wait").

Example:

use POSIX;
$i = system("some program");
if (WIFEXITED($i)) {
printf "exited normally with return code %d\n", WEXITSTATUS($i);
}
elsif (WIFSIGNALED($i)) {
printf "exited due to signal %d\n", WTERMSIG($i);
}
else {
print "exited for some other reason\n";
}