Inventory
  • Way of working

graphic
  • Configuration of Handscanner
Stmnt No
Type
Prompt Text
Voice Freq
Voice Msg
Data ID
Data Type
Max Chars
Min Chars
Input Dev
Next Yes
End No
Upload prefix
Upload Suffix
1
D
Bureau
E
 
 
 
 
-
30
00
-
02
99
BUR
 
 
2
D
PC
E
 
 
 
 
-
30
00
-
03
99
CPU
 
 
3
D
Monitor
E
 
 
 
 
-
30
00
-
04
04
MON
 
 
4
D
Monitor2
E
 
 
 
 
-
30
00
-
05
05
MO2
 
 
5
D
Printer
E
 
 
 
 
-
30
00
-
06
06
PRN
 
 
6
D
Scanner
E
 
 
 
 
-
30
00
-
07
07
SCA
 
 
7
D
Divers
E
 
 
 
 
-
30
00
-
07
01
DIV
 
 
  • Perl script
# Created by Daniel Paessens (Synstar CoE CS)

use DBI;

#
# Prepare used files
#
my $sourcefile    = "invent.txt";
my $outputfile    = "inventory.txt";
my $misfile  = "missing.txt";
my $mishtm = "missing.htm";
my $hierfile  = "hier.txt";

my $dbh = DBI->connect("dbi:Oracle:paradigm","paradigm","Passw0rd") || die("Can't connect to Oracle database: $DBI::errstr");

open(FILE,"$sourcefile") || die("Can't open invent.txt: $!");
open(INFILE,">$outputfile") || die("Can't open invout.txt: $!");
open(HIERFILE,">$hierfile") || die("Can't open hier.txt: $!");
open(MISFILE,">$misfile") || die("Can't open missing.txt: $!");
open(MISHTM,">$mishtm") || die("Can't open missing.htm: $!");


#
# Write header into file
#
print INFILE "TABLE Network_Resource\n \tnr_prim_search_key nr_room nr_floor\n";
print MISHTM ('<HTML>'."\n".'<BODY bgcolor="#9cc2e4">'."\n".'<font face="verdana">'."\n");
print MISHTM ('<table width="702" cellpadding="1" cellspacing="0" bgcolor="#3F2DFF">'."\n");
print MISHTM ('<tr>'."\n".'<td>'."\n".'<table width="700" bgcolor="#35A3D1">'."\n".'<tr>'."\n");
print MISHTM ('<td bgcolor="#7EBEE4" colspan="2" align="center">'."\n");
print MISHTM ('<font size="-1"><strong>Following assets were not found in database:</strong></font>'."\n".'</td>'."\n".'</tr>'."\n");

#
# Write Data into Assets file
#
foreach(readline(FILE))
       {
       chomp;
       my $prefix   = substr($_,0,3);
       if ($prefix =~ BUR)
             {
             $bur      = substr($_,3);
             }
       if ($prefix =~ CPU)
             {
             $cpu      = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$cpu'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$cpu\", \"$bur\",\"\" }\n";
             print HIERFILE "P$cpu\n";
             }
             else
             {
             print MISFILE "Asset $cpu not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">CPU:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$cpu".'</font></td></tr>'."\n");
             }
             }
             
       if ($prefix =~ MON)
             {
             $mon     = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$mon'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$mon\", \"$bur\",\"\" }\n";
             print HIERFILE "C$mon\n";
             }
             else
             {
             print MISFILE "Asset $mon not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">MON:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$mon".'</font></td></tr>'."\n");
             }
             }
       if ($prefix =~ MO2)
             {
             $mo2     = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$mo2'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$mo2\", \"$bur\",\"\" }\n";
             print HIERFILE "C$mo2\n";
             }
             else
             {
             print MISFILE "Asset $mo2 not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">MO2:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$mo2".'</font></td></tr>'."\n");
             }
             }
       if ($prefix =~ PRN)
             {
             $prn      = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$prn'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$prn\", \"$bur\",\"\" }\n";
             print HIERFILE "C$prn\n";
             }
             else
             {
             print MISFILE "Asset $prn not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">PRN:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$prn".'</font></td></tr>'."\n");
             }
             }
       if ($prefix =~ SCA)
             {
             $sca       = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$sca'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$sca\", \"$bur\",\"\" }\n";
             print HIERFILE "C$sca\n";
             }
             else
             {
             print MISFILE "Asset $sca not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">SCA:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$sca".'</font></td></tr>'."\n");
             }
             }
       if ($prefix =~ DIV)
             {
             $div       = substr($_,3);
              my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$div'") ||die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $id = $sth->fetchrow_array();
             if($id)
             {
             print INFILE "\t{\"$div\", \"$bur\",\"\" }\n";
             print HIERFILE "C$div\n";
             }
             else
             {
             print MISFILE "Asset $div not present in file\n";
             print MISHTM ('<tr><td align="right"><strong><font size="-1">DIV:</font></strong></td>');
             print MISHTM ('<td><font size="-1">'."$div".'</font></td></tr>'."\n");
             }
             }
       }

#
# Closing used files
#

print MISHTM ('</table>'."\n".'</td>'."\n".'</td>'."\n".'</table>'."\n".'</br>'."\n");
print MISHTM ('<a href="javascript:history.back()">Go back</a>'."\n".'</font>'."\n".'</body>'."\n".'</html>'."\n");
close(MISHTM);
close(MISFILE);
close(FILE);
close(INFILE);
close(HIERFILE);

#
# Prepare used files
#
my $sourcefile    = "hier.txt";
my $outputfile    = "res.txt";

#
# Prepare Database access
#
my $dbh = DBI->connect("dbi:Oracle:paradigm","paradigm","Passw0rd") || die("Can't connect to Oracle database: $DBI:errstr");


open(FILE,"$sourcefile") || die("Can't open hier.txt: $!");
open(INFILE,">$outputfile") || die("Can't open res.txt: $!");

print INFILE "TABLE Assignments\n \tnr_prim_search_key \n";

foreach(readline(FILE))
       {
       chomp;
       my $pre2      = substr($_,0,1);
       if ($pre2 =~ P)
             {
             $p   = substr($_,1);
             my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$p'") || die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $pid = $sth->fetchrow_array();
             }
       if ($pre2 =~ C)
             {
             $c   = substr($_,1);
             my $sth = $dbh->prepare("select id from paradigm.net_res where nr_prim_search_key = '$p'") || die("Can't prepare SQL statement: $DBI::errstr");
             $sth->execute || die("Can't execute SQL statement: $DBI::errstr");
             my $cid = $sth->fetchrow_array();
             print INFILE "\t{\"$pid\", \"$cid\" }\n";
             }
       }

#
# Closing used files
#
close(FILE);
close(INFILE);

#
# Closing DB connection
#
$dbh->disconnect() || die("Error disconnecting: $DBI::errstr");
  • Batch file
@echo off
Rem * Written by Daniel Paessens (Synstar CoE CS)
Rem * Version 0.1
Rem * File: c:\scripts\Inventory\inv.bat

Rem * Import new assets-location into DB
perl c:\scripts\Inventory\Inventory.pl

Rem - Transfer file
c:\scripts\pscp -q -pw scissors c:\scripts\inventory\inventory.txt root@lofty:/var/www/html/assetlog
c:\scripts\pscp -q -pw scissors c:\scripts\inventory\missing.htm root@lofty:/var/www/html/assetlog

Rem - Launch remote script
c:\scripts\plink -ssh -pw scissors root@lofty /opt/script/inventory.sh

Rem - Delete temporary files
del c:\scripts\inventory\res.txt
del c:\scripts\inventory\missing.txt
del c:\scripts\inventory\missing.htm
del c:\scripts\inventory\inventory.txt
  • Batch-file on Lofty
# Written by Daniel Paessens (Synstar CoE)
# Revision:  0.1
# Creation date: 15/05/2003
# File name:       inventory.sh
# File location:  /opt/scripts

pdm_userload -a -f /var/www/html/assetlog/inventory.txt