Modified Users - Part 2
This script will give an overview on all changes in VMTEL.txt-file against the Database.
  • Testing script file
# !/usr/bin/perl
# Created by Daniel Paessens (Synstar CoE CS)
#
# Version 0.2


use DBI;

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

open(FILE,"/opt/script/VMTEL.TXT") || die("Can't open VMTEL.TXT: $!");
open(INFILE,">$insertfile") || die("Can't open $insertfile: $!");
open(OUTHTM,">$outfilehtm");
print OUTHTM "<HTML>\n<BODY bgcolor=\"#9cc2e4\"><font face=\"verdana\">\n";
#top table (title)
print OUTHTM "<table width=\"702\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#3F2DFF\">\n";
print OUTHTM "<tr><td>\n";
print OUTHTM "<table width=\"700\" cellspacing=\"1\" bgcolor=\"#D4D4FA\">\n";
print OUTHTM "<tr>\n";
print OUTHTM "<td align=\"left\" valign=\"top\"><font size=\"-2\"><a href=\"http://lofty\">home</a></td>\n";
print OUTHTM "<td align=\"center\"><strong><font color=\"#0000ED\" size=\"-1\">TNG Unicenter Service Desk</font></BR>\n";
print OUTHTM "<font size=\"-2\" color=\"#7575FF\">B.E.I. Implementation by Synstar</font></strong></td>\n";
print OUTHTM "<td align=\"right\" valign=\"top\"><font size=\"-2\"><a href = \"javascript:history.back()\">back</a></td>\n";
print OUTHTM "</tr>\n";
print OUTHTM "</table></td></tr></table>\n";
#contents
print OUTHTM "<table width=\"702\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#3F2DFF\">\n";
print OUTHTM " <tr><td>\n";
print OUTHTM "  <table width=\"700\" cellspacing=\"1\" bgcolor=\"#35A3D1\">\n";
print OUTHTM "   <tr><td align=\"center\" bgcolor=\"#7EBEE4\" colspan=\"4\"><strong><font size=\"-1\">Changed USERS</font></strong></td></tr>\n";
print OUTHTM "     <tr bgcolor=\"#7EBEE4\">\n";
print OUTHTM "     <td><font size=\"-1\"><strong>Public Phone</strong></font></td>\n";
print OUTHTM "     <td><font size=\"-1\"><strong>First Name</strong></font></td>\n";
print OUTHTM "     <td><font size=\"-1\"><strong>Last name</strong></font></td>\n";
print OUTHTM "     </tr>\n";

foreach(readline(FILE))
       {
       chomp;
       my $first   = substr($_,0,4);$first   =~ s/\s+$//;
       my $second  = substr($_,5,8);$second  =~ s/\s+$//;
       my $third   = substr($_,14,4);$third  =~ s/\s+$//;
       my $fourth  = substr($_,19,3);$fourth =~ s/\s+$//;
       my $fifth   = substr($_,23,4);$fifth  =~ s/\s+$//;
       my $sixth   = substr($_,28,20);$sixth =~ s/\s+$//;
       my $seventh = substr($_,48);
       if($seventh =~ /^\)/)
             {
             $sixth .= ')';
             $seventh = substr($seventh,1);
             }
       my $sth = $dbh->prepare("select c_public_phone from paradigm.ctct where c_userid = '$second'") ||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 =~ $first)
             {
             }
       else
             {
             print INFILE "$first,  $sixth $seventh\n";
             print OUTHTM "     <tr>\n";
             print OUTHTM "     <td><font size=\"-1\">$first</font></td>\n";
             print OUTHTM "     <td><font size=\"-1\">$sixth</font></td>\n";
             print OUTHTM "     <td><font size=\"-1\">$seventh</font></td>\n";
             print OUTHTM "     </tr>\n";
             }
       }
print OUTHTM "<tr><td>&nbsp;</td></tr>";
print OUTHTM "  </table>\n";
print OUTHTM " </td></tr>\n";
print OUTHTM "</table>\n";
#bottom table (BACK button)
print OUTHTM "<table width=\"702\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#3F2DFF\">\n";
print OUTHTM "<tr><td>\n";
print OUTHTM "<table width=\"700\" cellspacing=\"1\" bgcolor=\"#D4D4FA\">\n";
print OUTHTM "<tr>\n";
print OUTHTM "<td><strong><font size=\"-1\"><a href = \"javascript:history.back()\">Go back</a></font></strong></td>\n";
print OUTHTM "</tr>\n";
print OUTHTM "</table>\n</tr></td>\n</table>\n";
print OUTHTM "</font></BODY>\n</HTML>\n";
close(OUTHTM);
close(FILE);
close(INFILE);
$dbh->disconnect() || die("Error disconnecting: $DBI::errstr");
  • Output
graphic
  • Batch-file on Lofty
# Written by Daniel Paessens Synstar
# Release:    0.1
# Filename: changes.sh
# File location:  /opt/script/

export ORACLE_HOME=/opt/ora/OraHome1
export ORACLE_BASE=/opt/ora/OraHome1
export ORACLE_SID=paradigm
export NX_ROOT=/opt/CAisd
cd /opt/script/VMTEL
perl /opt/script/VMTEL/change.pl
cp -f /opt/script/VMTEL/changes.htm /var/www/html/users/changes.htm