Email option on completion
authorJamie Cameron <jcameron@webmin.com>
Wed, 10 Feb 2010 05:45:09 +0000 (21:45 -0800)
committerJamie Cameron <jcameron@webmin.com>
Wed, 10 Feb 2010 05:45:09 +0000 (21:45 -0800)
at/CHANGELOG
at/create_job.cgi
at/freebsd-lib.pl
at/index.cgi
at/irix-lib.pl
at/lang/en
at/linux-lib.pl
at/macos-lib.pl
at/solaris-lib.pl

index 5a02e3f..784cfcf 100644 (file)
@@ -9,3 +9,5 @@ Converted all user interface code to use the new Webmin UI library.
 When editing a job, only the actual command entered is shown by default - the full command can be displayed using a new link.
 ---- Changes since 1.490 ----
 Added action logging for scheduled commands created and deleted using this module.
+---- Changes since 1.500 ----
+Added an option to send email on command completion.
index 9b7008d..d307fca 100755 (executable)
@@ -24,7 +24,7 @@ $in{'cmd'} =~ /\S/ || &error($text{'create_ecmd'});
 -d $in{'dir'} || &error($text{'create_edir'});
 
 # Create the job
-&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'});
+&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'}, $in{'mail'});
 &webmin_log("create", "job", $in{'user'}, \%in);
 &redirect("");
 
index 6f1219f..c9d76fe 100755 (executable)
@@ -26,13 +26,14 @@ closedir(DIR);
 return @rv;
 }
 
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-mail)
 sub create_atjob
 {
 local @tm = localtime($_[1]);
 local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
                $tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
 local @uinfo = getpwnam($_[0]);
 if ($uinfo[2] != $<) {
        # Only SU if we are not already the user
index 4331593..a98febd 100755 (executable)
@@ -100,6 +100,10 @@ print &ui_table_row($text{'index_dir'},
 print &ui_table_row($text{'index_cmd'},
                    &ui_textarea("cmd", $in{'ext_cmd'}, 5, 50));
 
+# Send email on completion
+print &ui_table_row($text{'index_mail'},
+                   &ui_yesno_radio("mail", 0));
+
 print &ui_table_end();
 print &ui_form_end([ [ undef, $text{'create'} ] ]);
 
index 8e3a4bf..1400c63 100755 (executable)
@@ -28,12 +28,13 @@ closedir(DIR);
 return @rv;
 }
 
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-mail)
 sub create_atjob
 {
 local @tm = localtime($_[1]);
 local $date = strftime "%H:%M %b %d", @tm;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
 local @uinfo = getpwnam($_[0]);
 if ($uinfo[2] != $<) {
        # Only SU if we are not already the user
index 93eca91..ecf6abb 100644 (file)
@@ -4,6 +4,7 @@ index_user=Run as user
 index_date=Run on date
 index_time=Run at time
 index_cmd=Commands to execute
+index_mail=Send email on completion?
 index_id=Job ID
 index_exec=Run at
 index_created=Created on
index ac2f49c..9f15440 100755 (executable)
@@ -27,13 +27,14 @@ closedir(DIR);
 return @rv;
 }
 
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
 sub create_atjob
 {
 local @tm = localtime($_[1]);
 local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
                $tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
 local @uinfo = getpwnam($_[0]);
 if ($uinfo[2] != $<) {
        # Only SU if we are not already the user
index cb05d6e..f534aa4 100755 (executable)
@@ -26,16 +26,17 @@ closedir(DIR);
 return @rv;
 }
 
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
 sub create_atjob
 {
 local @tm = localtime($_[1]);
 local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
                $tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\" >/dev/null 2>&1", 0); 
+local $mailflag = $_[4] ? "-m" : "";
+&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\" >/dev/null 2>&1", 0); 
 print AT $_[2];
 close(AT);
-&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"");
+&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\"");
 }
 
 # delete_atjob(id)
index f1304b0..273ab7c 100755 (executable)
@@ -29,12 +29,13 @@ closedir(DIR);
 return @rv;
 }
 
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
 sub create_atjob
 {
 local @tm = localtime($_[1]);
 local $date = strftime "%H:%M %b %d", @tm;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
 local @uinfo = getpwnam($_[0]);
 if ($uinfo[2] != $<) {
        # Only SU if we are not already the user