#!/usr/bin/perl #!C:\strawbery\perl\bin\perl.exe # Run a command or program on a group of Systems use strict; use warnings; use File::Basename; use Getopt::Long; qw(); my ($SysGroup, $HFILE, $SYS, @libfiles, @finfo, @DataList, @SysLst, @Parts, @Systems, @LIST, $LstCnt, $LINE, $truth, $sys, @list, $list, @columns, $LOGIN, $Sup, $LGN, $GRP, @systems, $GrpCnt, @group, $SysCnt, $grp, @Fields); GetOptions ("systems=s" => \$SYS , "login=s" => \$LGN , "group=s" => \$GRP ); @group = split(/,/, $GRP) if($GRP); @systems = split(/,/, $SYS) if($SYS); $GrpCnt=@group; $SysCnt=@systems; print "@list XX $GrpCnt YY $SysCnt\n"; @DataList = grep !/^\x23/, ; $truth=0; foreach $LINE (@DataList) { @Fields=split(/:/, $LINE); if($GRP) { foreach $grp (@group) { if ( "$LINE" =~ /:$grp:/){ $truth++; } } if ( $truth == $GrpCnt ) { push(@SysLst, $Fields[1]); } $truth=0; } elsif ($SYS) { foreach $sys (@systems) { if ( "$LINE" =~ /:$sys:/){ push (@SysLst, $Fields[1]); } } } } print "@SysLst\n"; print "$LGN\n"; my $cmd="start kitty.exe"; #my $args=" -l $LGN -agent -i \"C:\Program Files\PuTTY\MyKeys\RsaKey.ppk\" -load "; my $args=" -l $LGN -load "; sub run_in_bg; $Sup="i"; foreach my $System (@SysLst) { print "$System\n"; run_in_bg "$cmd $args $System$Sup"; } sub run_in_bg { my $pid = fork; die "Can't fork a new process" unless defined $pid; # child gets PID 0 if ($pid == 0) { exec(@_) || die "Can't exec $_[0]"; } # in case you wanted to use waitpid on it #return $pid; } __DATA__ a list of systems...