Commit ed6a6063 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add -q (quiet) option and use isatty() to keep the level of chattiness

down when invoked from the RPC server.
parent 0ec1a38a
......@@ -6,7 +6,7 @@
#
use English;
use Getopt::Std;
use POSIX qw(setsid);
use POSIX qw(isatty setsid);
use POSIX qw(strftime);
#
......@@ -30,13 +30,14 @@ use POSIX qw(strftime);
sub usage()
{
print(STDERR
"Usage: batchexp [-i [-w]] [-f] [-E description] [-g gid]\n".
"Usage: batchexp [-q] [-i [-w]] [-f] [-E description] [-g gid]\n".
" [-S reason] [-L reason] [-a <time>] [-l <time>]\n".
" -p <pid> -e <eid> <nsfile>\n".
"switches and arguments:\n".
"-i - swapin immediately; by default experiment is batched\n".
"-w - wait for non-batchmode experiment to preload or swapin\n".
"-f - preload experiment (do not swapin or queue yet)\n".
"-q - be less chatty\n".
"-S <str> - Experiment cannot be swapped; must provide reason\n".
"-L <str> - Experiment cannot be IDLE swapped; must provide reason\n".
"-a <nnn> - Auto swapout nnn minutes after experiment is swapped in\n".
......@@ -49,10 +50,11 @@ sub usage()
exit(-1);
}
my $optlist = "iE:g:e:p:S:L:a:l:fw";
my $optlist = "iE:g:e:p:S:L:a:l:fwq";
my $batchmode= 1;
my $frontend = 0;
my $waitmode = 0;
my $quiet = 0;
#
# Configure variables
......@@ -376,13 +378,18 @@ if (my $childpid = TBBackGround($logname)) {
if (!$waitmode) {
print("Experiment $pid/$eid is now configuring\n".
"You will be notified via email when the experiment is ".
"ready to use\n");
"ready to use\n")
if (! $quiet);
exit(0);
}
print("Waiting for " . ($batchmode ? "batch " : "") . "experiment $eid ".
"to finish " . ($frontend ? "preloading." : "swapping in.") . "\n");
print("You may type ^C at anytime; you will be notified via email later;\n".
"you will not actually interrupt the experiment itself.\n");
"to finish " . ($frontend ? "preloading." : "swapping in.") . "\n")
if (! $quiet);
if (isatty(STDIN) && !$quiet) {
print("You may type ^C at anytime; you will be notified via email.\n".
"You will not actually interrupt the experiment itself.\n");
}
# Give child a chance to run.
select(undef, undef, undef, 0.25);
......@@ -400,7 +407,8 @@ if (my $childpid = TBBackGround($logname)) {
#
waitpid($childpid, 0);
print("Done. Exited with status: $?\n");
print("Done. Exited with status: $?\n")
if (! $quiet);
exit($? >> 8);
}
......@@ -736,6 +744,9 @@ sub ParseArgs()
if (defined($options{"f"})) {
$frontend = 1;
}
if (defined($options{"q"})) {
$quiet = 1;
}
#
# pid,eid,gid get passed along as shell commands args; must taint check.
......
......@@ -8,6 +8,7 @@
use English;
use Getopt::Std;
use POSIX qw(isatty setsid);
#
# This gets invoked from the Web interface. Terminate an experiment.
......@@ -23,16 +24,18 @@ use Getopt::Std;
sub usage()
{
print(STDERR
"Usage: endexp [-b | -w] <pid> <eid>\n".
"Usage: endexp [-q] [-b | -w] <pid> <eid>\n".
"switches and arguments:\n".
"-w - wait for non-batchmode experiment terminate\n".
"-q - be less chatty\n".
"<pid> - The project the experiment belongs to\n".
"<eid> - The experiment name (id)\n");
exit(-1);
}
my $optlist = "bw";
my $optlist = "bwq";
my $waitmode = 0;
my $batch = 0;
my $quiet = 0;
#
# Exit codes are important; they tell the web page what has happened so
......@@ -116,6 +119,9 @@ if (defined($options{"b"})) {
if (defined($options{"w"})) {
$waitmode = 1;
}
if (defined($options{"q"})) {
$quiet = 1;
}
usage()
if ($waitmode && $batch);
......@@ -352,14 +358,20 @@ if (! $batch) {
# Parent exits normally, except if in waitmode.
#
if (!$waitmode) {
ExitWithStatus(0,
"Experiment $pid/$eid is now terminating.\n".
"You will be notified via email when the experiment has been\n".
"torn down, and you can reuse the experiment name.\n");
print("Experiment $pid/$eid is now terminating.\n".
"You will be notified via email when termination is ".
"complete.\n")
if (! $quiet);
exit(0);
}
print("Waiting for experiment $eid to finish terminating.\n")
if (! $quiet);
if (isatty(STDIN) && !$quiet) {
print("You may type ^C at anytime; you will be notified via email.".
"\n".
"You will not actually interrupt the experiment itself.\n");
}
print("Waiting for experiment $eid to finish terminating.\n");
print("You may type ^C at anytime; you will be notified via email;\n".
"later; you will not actually interrupt the experiment itself.\n");
# Give child a chance to run.
select(undef, undef, undef, 0.25);
......@@ -377,7 +389,8 @@ if (! $batch) {
#
waitpid($childpid, 0);
print("Done. Exited with status: $?\n");
print("Done. Exited with status: $?\n")
if (! $quiet);
exit($? >> 8);
}
}
......
......@@ -8,7 +8,7 @@
use English;
use Getopt::Std;
use POSIX qw(setsid);
use POSIX qw(isatty setsid);
#
# This gets invoked from the Web interface.
......@@ -18,11 +18,12 @@ use POSIX qw(setsid);
sub usage()
{
print(STDERR
"Usage: swapexp [-b | -w] [-i | -a | -f] [-r] [-e]\n".
"Usage: swapexp [-q] [-b | -w] [-i | -a | -f] [-r] [-e]\n".
" <-s in | out | restart | modify | pause>\n".
" <pid> <eid> [<nsfile>]\n".
"switches and arguments:\n".
"-w - wait for non-batchmode experiment swap/modify\n".
"-q - be less chatty\n".
"-r - reboot nodes when doing a modify experiment\n".
"-e - restart event scheduler when doing a modify experiment\n".
"-s <op> - Operation to perform; one of those listed above\n".
......@@ -31,7 +32,7 @@ sub usage()
"<nsfile> - Optional NS file to parse for experiment modify\n");
exit(-1);
}
my $optlist = "biafres:w";
my $optlist = "biafres:wq";
#
# Exit codes are important; they tell the web page what has happened so
......@@ -81,6 +82,7 @@ my $autoswap = 0;
my $force = 0;
my $reboot = 0;
my $waitmode = 0;
my $quiet = 0;
my $eventsys_restart = 0;
my $errorstat= -1;
my $modifyHosed = 0;
......@@ -143,6 +145,9 @@ if (defined($options{"r"})) {
if (defined($options{"e"})) {
$eventsys_restart = 1;
}
if (defined($options{"q"})) {
$quiet = 1;
}
if (defined($options{"s"})) {
$inout = $options{"s"};
......@@ -613,13 +618,19 @@ if (! $batch) {
# Parent exits normally, except if in waitmode.
#
if (!$waitmode) {
print "Experiment $pid/$eid is now being $action.\n".
"You will be notified via email when the this is done.\n";
print("Experiment $pid/$eid is now being $action.\n".
"You will be notified via email when the this is done.\n")
if (! $quiet);
exit(0);
}
print("Waiting for experiment $eid to finish its swap${action}\n");
print("You may type ^C at anytime; you will be notified via email;\n".
"later; you will not actually interrupt the experiment itself.\n");
print("Waiting for experiment $eid to finish its swap${action}\n")
if (! $quiet);
if (isatty(STDIN) && !$quiet) {
print("You may type ^C at anytime; you will be notified via email.".
"\n".
"You will not actually interrupt the experiment itself.\n");
}
# Give child a chance to run.
select(undef, undef, undef, 0.25);
......@@ -637,7 +648,8 @@ if (! $batch) {
#
waitpid($childpid, 0);
print("Done. Exited with status: $?\n");
print("Done. Exited with status: $?\n")
if (! $quiet);
exit($? >> 8);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment