chiark / gitweb /
Actual error messages
[modbot-ulm.git] / stump / bin / email-server.pl
index c54de157862067094a4ae520d4efa045e35847fa..6170cb7eda578cc699db7c1eda45ed297665a753 100755 (executable)
@@ -248,15 +248,15 @@ sub reply {
   open( SENDMAIL, "|$sendmail '$address'" ) 
        || die "Could not start sendmail in $sendmail";
 
-  print SENDMAIL "From: $To\n";
-  print SENDMAIL "To: $address\n";
-  print SENDMAIL "Subject: Re: $Subject\n";
+  print SENDMAIL "From: $To\n" or die $!;
+  print SENDMAIL "To: $address\n" or die $!;
+  print SENDMAIL "Subject: Re: $Subject\n" or die $!;
 
-  print SENDMAIL "\n";
+  print SENDMAIL "\n" or die $!;
 
-  print SENDMAIL "$msg\n";
+  print SENDMAIL "$msg\n" or die $!;
 
-  close( SENDMAIL );
+  close( SENDMAIL ) or die "$? $!";
 
 }
 
@@ -340,7 +340,7 @@ sub command_get {
 
     my $reply_body = "";
 
-    open( FILE, $file );
+    open( FILE, $file ) or die $!;
     $reply_body .= $_ while( <FILE> );
     close( FILE );
 
@@ -351,32 +351,32 @@ sub command_get {
   }
 }
 
-sub command_set {
-  my $arg = pop( @_ );
-
-  my $file = &file_from_arg( $arg );
-  my $mode = &mode_from_arg( $arg );
-
-  &user_error( "File $arg is not in the list of available files." )
-    if( !$file );
-
-  if( -w $file && -f $file && $mode eq "rw" ) {
-
-    my $reply_body = "Succeeded in writing to file '$arg':\n\n$Body";
-
-    if( open( FILE, ">$file" ) ) {
-      print FILE $Body;
-      close( FILE );
-    } else {
-      $reply_body = "Failed to write to file $arg:\n\n$Body";
-    }
-
-    &reply( $reply_body );
-
-  } else { 
-    &user_error( "File $arg does not exist or is not writable" );
-  }
-}
+sub command_set {
+  my $arg = pop( @_ );
+# 
+  my $file = &file_from_arg( $arg );
+  my $mode = &mode_from_arg( $arg );
+# 
+  &user_error( "File $arg is not in the list of available files." )
+    if( !$file );
+# 
+  if( -w $file && -f $file && $mode eq "rw" ) {
+# 
+    my $reply_body = "Succeeded in writing to file '$arg':\n\n$Body";
+# 
+    if( open( FILE, ">$file" ) ) {
+      print FILE $Body;
+      close( FILE );
+    } else {
+      $reply_body = "Failed to write to file $arg:\n\n$Body";
+    }
+# 
+    &reply( $reply_body );
+# 
+  } else { 
+    &user_error( "File $arg does not exist or is not writable" );
+  }
+}
 
 sub main {
   &init;