---- Changes since 1.510 ----
Fixed a bug that broke remote command execution with parameters.
Added a new parameter type for selecting multiple items from a menu.
+---- Changes since 1.530 ----
+Added an option for custom commands to have their output displayed without any Webmin UI, in a selectable MIME type.
$cmd{'usermin'} = int($o[5]);
$cmd{'timeout'} = int($o[6]);
$cmd{'clear'} = int($o[7]);
+ $cmd{'format'} = $o[8] eq '-' ? undef : $o[8];
}
elsif ($f =~ /^(\d+)\.edit$/) {
# Read file-editor file
$c->{'user'}," ",int($c->{'raw'})," ",int($c->{'su'})," ",
int($c->{'order'})," ",int($c->{'noshow'})," ",
int($c->{'usermin'})," ",int($c->{'timeout'})," ",
- int($c->{'clear'}),"\n");
+ int($c->{'clear'})," ",($c->{'format'} || "-"),"\n");
}
# Command timeout
print &ui_table_row(&hlink($text{'edit_timeout'},"timeout"),
- &ui_opt_textbox("timeout", $cmd->{'timeout'}, 6, $text{'default'}).
- " ".$text{'edit_secs'});
+ &ui_opt_textbox("timeout", $cmd->{'timeout'} || undef, 6,
+ $text{'default'})." ".$text{'edit_secs'});
# Clear environment?
print &ui_table_row(&hlink($text{'edit_clear'},"clear"),
&ui_yesno_radio("clear", $cmd->{'clear'}));
+# Output format
+print &ui_table_row(&hlink($text{'edit_format'}, "format"),
+ &ui_opt_textbox("format", $cmd->{'format'}, 20, $text{'edit_format0'},
+ $text{'edit_format1'}));
+
# Show Webmin servers to run on
@servers = &list_servers();
if (@servers > 1) {
edit_timeoutdef=Forever
edit_secs=seconds
edit_clear=Clear environment variables?
+edit_format=Output style
+edit_format0=Show in Webmin UI
+edit_format1=Output with MIME type
edit_servers=Run on Webmin servers
edit_this=this server
edit_clone=Clone
save_eorder=Ordering on main page must be a number
save_etimeout=Missing or invalid maximum time to wait
save_eusermin=Commands that run on other servers cannot be run from Usermin
+save_eformat=Invalid output MIME type
run_err=Failed to execute command
run_ecannot=You are not allowed to run this command
@servers = &list_servers();
# Run and display output
-&ui_print_unbuffered_header($cmd->{'desc'}, $text{'run_title'}, "", -d "help" ? "run" : undef);
+if ($cmd->{'format'}) {
+ print "Content-type: ",$cmd->{'format'},"\n";
+ print "\n";
+ }
+else {
+ &ui_print_unbuffered_header($cmd->{'desc'}, $text{'run_title'}, "",
+ -d "help" ? "run" : undef);
+ }
&remote_error_setup(\&remote_custom_handler);
if (@{$cmd->{'hosts'}}) {
$txt .= 'on';
}
- print &text($txt, "<tt>".&html_escape($displaystr)."</tt>",
- $server->{'desc'} || "<tt>$server->{'host'}</tt>"),"\n";
- print "<pre>" if (!$cmd->{'raw'});
+ if (!$cmd->{'format'}) {
+ print &text($txt, "<tt>".&html_escape($displaystr)."</tt>",
+ $server->{'desc'} || "<tt>$server->{'host'}</tt>"),"\n";
+ print "<pre>" if (!$cmd->{'raw'});
+ }
$remote_custom_error = undef;
if ($h == 0) {
# Run locally
}
if (!$remote_custom_error) {
print $out if ($h != 0);
- if (!$got) {
+ if (!$got && !$cmd->{'format'}) {
print "<i>$text{'run_noout'}</i>\n";
}
}
- print "</pre>\n" if (!$cmd->{'raw'});
- if ($remote_custom_error) {
- print "<b>$remote_custom_error</b><p>\n";
- }
- elsif ($timeout) {
- print "<b>",&text('run_timeout', $cmd->{'timeout'}),"</b><p>\n";
+
+ if (!$cmd->{'format'}) {
+ print "</pre>\n" if (!$cmd->{'raw'});
+ if ($remote_custom_error) {
+ print "<b>$remote_custom_error</b><p>\n";
+ }
+ elsif ($timeout) {
+ print "<b>",&text('run_timeout',
+ $cmd->{'timeout'}),"</b><p>\n";
+ }
}
# Only log non-upload inputs
}
&webmin_log("exec", "command", $cmd->{'id'}, \%cmdin);
unlink(@unlink) if (@unlink);
-&ui_print_footer("", $text{'index_return'});
+if (!$cmd->{'format'}) {
+ &ui_print_footer("", $text{'index_return'});
+ }
sub remote_custom_handler
{
$cmd->{'order'} = $in{'order_def'} ? 0 : int($in{'order'});
$cmd->{'timeout'} = $in{'timeout_def'} ? 0 : int($in{'timeout'});
$cmd->{'clear'} = $in{'clear'};
+ if ($in{'format_def'}) {
+ delete($cmd->{'format'});
+ }
+ else {
+ $in{'format'} =~ /^[a-z0-9\.\_\-]+\/[a-z0-9\.\_\-]+/i ||
+ &error($text{'save_eformat'});
+ $cmd->{'format'} = $in{'format'};
+ }
$cmd->{'noshow'} = $in{'noshow'};
$cmd->{'usermin'} = $in{'usermin'};
@hosts = split(/\0/, $in{'hosts'});