Commit b99ee25e authored by Mac Newbold's avatar Mac Newbold

This is a script designed to be edited for easy data entry of any part

of the database. Feel free to make changes, and if they'll be useful to
others, please commit them.
parent 60d321e1
#!/usr/local/bin/perl -w
#!/usr/local/bin/perl -w
my $d=0; #debug
use Mysql;
my $dbh = Mysql->connect("localhost","tbdb","script","none");
my $sth ="";
my $cmd ="";
sub failed {
my ($cmd, $errstr) = @_;
print "Failed Command:\n$cmd\nError string is:$errstr\n";
}
#foreach my $node ( 21..40 ) {
# foreach my $ifc ( 0..3 ) {
# my $node_id = "tbpc".sprintf("%02d",$node);
# print "$node_id,eth$ifc: cable #? ";
# $_ = <STDIN>; chop;
# my $cable = $_;
# my $card = int (($node-1) / 6) + 3;
# print "",(int ((($node-1) % 6) / 3)),"\t",(($node+1) % 3),"\n";
# my $port = (int ((($node-1) % 6) / 3))+25+(($node-1) % 3)*8+$ifc*2 ;
# print "Inserting ($cable,$node_id,$ifc,$card,$port)...\n";
# $cmd = "replace into wires ".
# "(cable,node_id1,card1,card2,port2,port1,node_id2,type)".
# " values ($cable,'$node_id',$ifc,$card,$port,1,'cisco','Node');";
# $sth = $dbh->query($cmd) || &failed($cmd,$sth->errstr) && last;
# }
#}
foreach my $node ( 1..40 ) {
my $node_id = "tbpc".sprintf("%02d",$node);
print "$node_id,eth4: cable #? ";
$_ = <STDIN>; chop;
my $cable = $_;
print "$node_id,eth4: card #? ";
$_ = <STDIN>; chop;
my $card = $_;
print "$node_id,eth4: port #? ";
$_ = <STDIN>; chop;
my $port = $_;
print "Inserting ($cable,$node_id,4,$card,$port)...\n";
$cmd = "replace into wires ".
"(cable,node_id1,card1,card2,port2,port1,node_id2,type)".
" values ($cable,'$node_id',4,$card,$port,1,'cisco2','Control');";
$sth = $dbh->query($cmd) || &failed($cmd,$sth->errstr) && last;
}
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