aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/ssendfile.pl
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
committerJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
commit2a0c0a3dbbdf7fa5040953c0b0d88ad6f62c011e (patch)
tree92c7cbf54272466b46f64e5dc8d1ddb429858836 /web/nms.gathering.org/ssendfile.pl
parentfe0be5960aac1f9bb600dbf853d862a9f4e60de8 (diff)
Initial commit. Source; TG13-goodiebag.
Diffstat (limited to 'web/nms.gathering.org/ssendfile.pl')
-rwxr-xr-xweb/nms.gathering.org/ssendfile.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/web/nms.gathering.org/ssendfile.pl b/web/nms.gathering.org/ssendfile.pl
new file mode 100755
index 0000000..ec2ebb8
--- /dev/null
+++ b/web/nms.gathering.org/ssendfile.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib '../../include';
+use POSIX;
+
+my $delaytime = 30;
+my $poll_frequency = 60;
+
+sub mylog {
+ my $msg = shift;
+ my $time = POSIX::ctime(time);
+ $time =~ s/\n.*$//;
+ printf STDERR "[%s] %s\n", $time, $msg;
+}
+
+if ($#ARGV != 1) {
+ die("Error in arguments passed\n".
+ "./ssendfile.pl addr configfile\n");
+}
+
+my $conn = nms::switch_connect($ARGV[0]);
+if (!defined($conn)) {
+ die("Could not connect to switch.\n");
+}
+
+open(CONFIG, $ARGV[1]);
+while (<CONFIG>) {
+ my $cmd = $_;
+ $cmd =~ s/[\r\n]+//g;
+ print "Executing: `$cmd`\n";
+# if ($cmd =~ /ip ifconfig swif0 (\d{1-3}\.\d{1-3}\.\d{1-3}\.\d{1-3})/) {
+# print "New ip: $1\n";
+# $conn->cmd( String => $cmd,
+# Timeout => 3);
+# $conn = nms::switch_connect($1);
+# if (!defined($conn)) {
+# die "Could not connect to new ip: $1\n";
+# }
+# }
+# else {
+ my @data = nms::switch_exec($cmd, $conn);
+ foreach my $line (@data) {
+ $line =~ s/[\r\n]+//g;
+ print "$line\n";
+ }
+# }
+}