Imported Upstream version 3.3.2
[debian/amanda] / perl / Amanda / Script_App.pm
index 3b6ff69a0e5d378728e26ee01753828720d4061f..f0ce34919ae837c9cb1190cc4ccd0985e9563135 100644 (file)
@@ -1,5 +1,5 @@
 # vim:ft=perl
-# Copyright (c) 2008,2009 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2008-2012 Zmanda, Inc.  All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License version 2 as published
@@ -23,6 +23,7 @@ no warnings;
 no strict;
 $GOOD  = 0;
 $ERROR = 1;
+$FAILURE = 2;
 
 use strict;
 use warnings;
@@ -60,6 +61,7 @@ sub new {
        $execute_where = "client";
     }
     Amanda::Util::setup_application($name, $execute_where, $CONTEXT_DAEMON);
+    debug("Arguments: " . join(' ', @ARGV));
 
     #initialize config client to get values from amanda-client.conf
     config_init($CONFIG_INIT_CLIENT, undef);
@@ -116,11 +118,13 @@ sub print_to_server {
     } elsif ($self->{action} eq "backup") {
        if ($status == $Amanda::Script_App::GOOD) {
             print {$self->{mesgout}} "| $msg\n";
-       } else {
+       } elsif ($status == $Amanda::Script_App::ERROR) {
             print {$self->{mesgout}} "? $msg\n";
+       } else {
+            print {$self->{mesgout}} "sendbackup: error $msg\n";
        }
     } elsif ($self->{action} eq "restore") {
-        print STDOUT "$msg\n";
+        print STDERR "$msg\n";
     } elsif ($self->{action} eq "validate") {
         print STDERR "$msg\n";
     } else {
@@ -180,6 +184,10 @@ sub do {
        $self->{action} = 'validate';
     }
 
+    if ($action eq 'backup') {
+       $self->_set_mesgout();
+    }
+
     # now convert it to a function name and see if it's
     # defined
     my $function_name = "command_$command";