use strict;
use warnings;
use Getopt::Std;
+use File::Basename;
our ($opt_s, $opt_r, $opt_k, $opt_h);
getopts('hs:p:kr');
&checkArgs();
#--- on these PCs the script should be restarted:
-#my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455');
-my @PCList = ('lxg0447');
-my $args = "-d"; #- arguments of script to be restarted
+my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455');
+#my @PCList = ('lxg0447');
+my $args = "-d"; #- arguments of script to be restarted
&main();
sub main
{
- #--- on these PCs the script should be restarted:
- #my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455');
- my @PCList = ('lxg0447');
-
foreach my $PC (@PCList) {
- print "restart on $PC ...\n";
+ &printMessage($PC);
if( $opt_k || $opt_r ){
#--- get PIDs of running scripts
}
}
+sub printMessage
+{
+ my $PC = shift;
+
+ my $prog_name = basename($opt_s);
+
+ if($opt_k){
+ print "kill $prog_name on $PC ...\n";
+ }
+ elsif($opt_r){
+ print "restart $prog_name on $PC ...\n";
+ }
+ else{
+ print "start $prog_name on $PC ...\n";
+ }
+}
+
sub showHelp
{
print << 'EOF';
-k : Kill a running script without restarting.
-h : Print this help.
+ If there is only -s <name> specified this script will
+ remotely start <name> program without trying to kill
+ it first.
+
EOF
}