Ontape returning 0 even though the command failed
Posted in 2015
Topics: Backup & Restore, Error Codes & Troubleshooting
I am executing the informix ontape command for backup via the Python
commands.getstatusoutput() function call.
Example:
(rc, op) = commands.getstatusoutput("source /source ; ontape -v -s -L 0 -t
STDIO | /bin/gzip > /backup/ontape_backup.gz
")
After executing the above function, the return code rc is 0 and the output
message op is "Archive failed - ISAM error: An error has occurred during
archive back up.
What I don't understand is why is it returning 0 even though the command
failed.
Is it something related to the behaviour of ontape command?
What is the best way to find out whether the command has failed or not?
Python version used is 2.6.6
Hi,
I would guess you are getting the exit code from the gzip (which does not fail
for the amount of data passing).
Try using a BACKUP_FILTER/RESTORE_FILTER instead, which is set in onconfig and
used internally.
Best regards,
Marcus Haarmann
----- Ursprüngliche Mail -----
Von: "KUSHWANTH RAM" <kushwanth7@gmail.com>
An: ids@iiug.org
Gesendet: Donnerstag, 26. März 2015 06:15:07
Betreff: Ontape returning 0 even though the command failed [34868]
I am executing the informix ontape command for backup via the Python
commands.getstatusoutput() function call.
Example:
(rc, op) = commands.getstatusoutput("source /source ; ontape -v -s -L 0 -t
STDIO | /bin/gzip > /backup/ontape_backup.gz
")
After executing the above function, the return code rc is 0 and the output
message op is "Archive failed - ISAM error: An error has occurred during
archive back up.
What I don't understand is why is it returning 0 even though the command
failed.
Is it something related to the behaviour of ontape command?
What is the best way to find out whether the command has failed or not?
Python version used is 2.6.6
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
Because you are piping the output to gzip and the shell returns the return
code of the last utility in the pipeline, not the first (ie ontape).
Apparently gzip doesn't think it ezperienced an error if the input
file/stream is empty.
Art
Art S. Kagel, President and Principal Consultant
ASK Database Management
www.askdbmgt.com
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Thu, Mar 26, 2015 at 1:15 AM, KUSHWANTH RAM <kushwanth7@gmail.com> wrote:
> I am executing the informix ontape command for backup via the Python
> commands.getstatusoutput() function call.
>
> Example:
>
> (rc, op) = commands.getstatusoutput("source /source ; ontape -v -s -L 0 -t
> STDIO | /bin/gzip > /backup/ontape_backup.gz
>
> ")
>
> After executing the above function, the return code rc is 0 and the output
> message op is "Archive failed - ISAM error: An error has occurred during
> archive back up.
>
> What I don't understand is why is it returning 0 even though the command
> failed.
>
> Is it something related to the behaviour of ontape command?
>
> What is the best way to find out whether the command has failed or not?
>
> Python version used is 2.6.6
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e011840381a618e05122e9f7a
Another solution would be:
(rc, op) = commands.getstatusoutput("source /source ; ontape -v -s -L 0 -t
STDIO | /bin/gzip ; exit ${PIPESTATUS[0]} > /backup/ontape_backup.gz")