📄 push-datacollection.pl
字号:
#!/usr/bin/perl sub usage { print "push-datacollection.pl [nodelist]\n";}sub main { $verbose = 1; $count = 0; $line_num = 0; # Figure out where the node list is if (scalar(@ARGV) < 1) { if ($verbose) {print "Using STDIN\n";} } else { if ($verbose) {print "Using $ARGV[0]\n"; } open(NODELIST, $ARGV[0]) or die "Could not open $ARGV[0]\n"; } # Read in node list while($line = scalar(@ARGV) < 1? <STDIN> : <NODELIST>) { $line_num++; if ( (substr $line, 0, 1) ne '#'){ if ($line =~ /(\S+)\s+([\d\.]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(I2?)/) { push @device, $1; push @ip, $2; push @hw, $3; push @gw, $4; push @name, $5; if ($6 eq "I") {push @I2, 0;} elsif ($6 eq "I2") {push @I2, 1;} else { print "1Syntax error at line $line_num\n"; pop @device; pop @ip; pop @hw; pop @gw; pop @name; } } else { print "Sytax error at line $line_num\n"; } } } print "Tarring up datacollection\n"; $command = "tar czf /tmp/datacollection.tgz -C /home/am0/yipal/ron datacollection-export"; @args = ("tcsh", "-c", $command); system(@args); for($i=0; $i<scalar(@name); $i++) { print "Working on $name[$i]\n"; # commands of this form: # cat /tmp/datacollection.tgz | ssh ron@mit.ron.lcs.mit.edu tar xzf - -C yipal/ $command = "cat /tmp/datacollection.tgz | ssh $name[$i] -l ron tar xzf - -C yipal/"; @args = ("tcsh", "-c", $command); system(@args); sleep 1; } # remove temporary tar files print "Removing datacollection.tgz\n"; @args = ("rm", "/tmp/datacollection.tgz"); system(@args);}&main();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -