/ Published in: Perl
Author: jsinix([email protected]
This script can be used to create, delete and update device inventory. This is a basic script that can be modified and improved upon to make it serve better .
This script can be used to create, delete and update device inventory. This is a basic script that can be modified and improved upon to make it serve better .
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl -w use strict; use Switch; print header; my @fieldnames = param(); my $device = param('devicename'); if($devicelen > 15) { } my $description = param('description'); if($descriptionlen > 150) { } my $password = param('pass'); #print $password; #my $pwdbit0 = pass_bit($password); #print $pwdbit0; my $replacebit = param('replace'); my $selection = param('select'); switch ($selection) { case "add" {add_entry($device, $description);} case "query" {query_entry($device);} case "remove" {remove_entry($device);} } sub add_entry { my ($dev1, $des1) = @_; my $pbit = is_present($dev1); my $pwdbit1 = pass_bit($password); if($pwdbit1 != 1) { } if($pbit eq "1") { if($replacebit == 1) { create_device($dev1, $des1); } else { print "Device already present. If you want to replace select the 'Replace existing entry' and try again."; } } else { create_device($dev1, $des1); } } sub query_entry { my ($dev2) = @_; my $qqbit = is_present($dev2); my $file_location = "DeviceDB/$dev2"; if($qqbit == 1) { my $result1 = `cat $file_location`; } else { } } sub remove_entry { my ($dev5) = @_; my $ppbit = is_present($dev5); my $file_location = "DeviceDB/$dev5"; my $pwdbit2 = pass_bit($password); if($pwdbit2 != 1) { } if($ppbit == 1) { `rm $file_location`; } else { } } sub is_present { my ($dev3) = @_; my $file_location = "DeviceDB/"; my $res = `ls -1 $file_location | grep $dev3`; if($res) { } else { } } sub create_device { my ($dev4,$des4) = @_; my $file_location = "DeviceDB/$dev4"; } sub pass_bit { my ($pass1) = @_; if($pass1 eq "12345") { } else { } } #my $link = "#"; #my $text = "Homepage"; #print "<br><br><br>"; #print "<a href=\"$link\">$text</a>"."\t"; print end_html;
URL: www.jsinix.com