Wednesday, August 26, 2009

How to fix: Windows cannot access the specified device, path, or file.


After some group policy changes I was getting this error upon trying to install various applications which I had copied from a network share.

But after clicking the Unblock button above the problem was resolved.


How to install RRDs module for RRDTool in perl on Win32

Install Activestate Perl: http://www.activestate.com/activeperl/

Direct link: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.1.1006-MSWin32-x86-291086.msi

Download the rrdtool zip file for windows

Find it here: http://oss.oetiker.ch/rrdtool/pub/?M=D

Direct link: http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30-win32-perl510.zip

Unzip to a temp folder

Open a command prompt and change to the following directory

C:\Temp\rrdtool-1.2.30-win32-perl510\data\rrd2\rrdtool-1.2.30\bindings\perl-shared>

Type ppm install RRDs.ppd

Good to go!

Tuesday, August 18, 2009

How to Create a dynamic DSN for Win32::ODBC database


#! c:\perl\bin\perl
use Win32::ODBC;

$DriverType = "Microsoft Access Driver (*.mdb)";
$DSN = "Win32 ODBC --MS_Access--";
$Dir = "c:\\perl";
$DBase = "myDB.mdb";

Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType,("DSN=$DSN", "Description=DSN for Perl", "DBQ=$Dir\\$DBase", "DEFAULTDIR=$Dir", "UID=", "PWD=")) or die "ConfigDSN(): Could not add temporary DSN" . Win32::ODBC::Error();
$db=new Win32::ODBC($DSN) or die "couldn't ODBC $DSN ", Win32::ODBC::Error(), "\n";
$query = "select * from table";
!$db->Sql($query) or die "query $query failed ", $db->Error(), "\n";

while($db->FetchRow())
{
my %Data = $db->DataHash();
foreach my $key(keys(%Data))
{
print $key," -> ",$Data{$key};
}
}

Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, $DriverType, "DSN=$DSN") or die "ConfigDSN(): Could not remove temporary DSN ", Win32::ODBC::Error();

Monday, August 17, 2009

How to redeem iTunes app codes from an iPhone or iPod touch.



This one is real easy, but not obvious at first.
Open the app store, then under the featured apps scroll to the very
bottom.
Tap on the redeem app.
It will ask for your iTunes code and your apple account password.
It will install the app, have fun!

Sunday, August 16, 2009

How to fix blogger errors trying to add rss feed

I have a blog that I am trying to add as an RSS feed to google reader, however when I click the rss link it gives me this error: User does not have permission to read this blog.

Through some trial and error I found a fix for this problem.

It occurs when the blogger permissions tab is set to allow only authors to read the blog, I am an author, I'm the admin also, but I still cannot add the rss feed.
I believe this is a security concern and cannot be fixed, but as a workaround, temporarily set the Blog Readers permission to anybody, then add the rss feed to your rss reader, then reset the permissions to only authors.

Works great!

Automatically fill in a PDF form with a perl script

I am using perl version 5.10, and I installed CAM::PDF (version 1.52) by using ppm.


#!/usr/bin/perl
use strict;
use warnings;
use CAM::PDF;

my $infile = input.pdf';
my $outfile = output.pdf';
my $pdf = CAM::PDF->new($infile) or die 'error';
my @FIELDS = $pdf->getFormFieldList();

foreach my $field ( @FIELDS ) {
if ($field =~ /^c/) {
my $ff_obj = $pdf->getFormField($field);
$ff_obj->{value}->{value}->{AS}->{value} = 'Yes'; #This line sets a check in the checkbox fields
}

else {
$pdf->fillFormFields($field => $field); #This line sets the value of the field to the field name.
}
}
$pdf->cleanoutput($outfile);


It seems that on adobe 1.6 files with interactive forms some of the coding is lost and when the output file is opened there is an error stating “this document enabled extended features in adobe reader. the document has been changed”

This seems to be due to incompatibilities in the version of CAM::PDF.

It works fine under older versions of pdf files.


Monday, August 10, 2009

Using system commands in perl executable causes console window to popup

After converting a perl program to an executable file using perl2exe or pp (PAR Packer) under windows I had a problem arise.
I was using a system call to print an html file from a tkx based perl program.
All was great until I tried to compile with the -gui command in order to prevent the console window from showing while processing the program.
Which worked well except when the user initiated a print job.
A console window would popup and would not go away until the user clicked ok in the print dialog.
After hours of searching I found this solution, very simple, just add the following code to the perl script and recompile to exe.


Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow;



See the source for this solution here.

Thanks Activestate!

Perl Printing in Windows

In order to print a document from a perl based program the easiest option I have found is to save the document by printing to a File Handle, then run a system command to print the document.

This method is great for dynamically creating a formatted HTML document, saving it to a file by printing to the File Handle, then calling the system comman
d below to print the html document.

system('rundll32.exe %SystemRoot%\system32\mshtml.dll,PrintHTML "file://c:\perl\myfile.html"');
This command will open the printer dialog so the user can select a printer and other options.



Thanks to Rob's site for showing me how to use the rundll32 command.

Using the system command creates a problem when trying to run a console free application, however I will address this in another post.


Tuesday, August 4, 2009

RRDTool wireless client tracking



Here is a sample of one of the tools I have recently built.
This graph is queried from a web based form which allows searching of access points by building, client, SSID, etc. The graph type is selectable and dynamically built based upon the user input to the form. It allows selection of various time frames for the graph including the sample above showing the previous month.
Also, the web form allows to display multiple client signal levels overlaid on the same line graph.
(I will have to grab a sample of this for another post.)
I haven't seen any RRDTool graphs quite like this that give a visual representation of wireless client movement from AP to AP, so I thought it would be nice to post this as a sample of the possibilities presented by the amazing RRDTool.
Thanks Tobi!

First Post - Thanks to All

For years I have managed a large Campus Network as a lead Network Engineer and I have specialized in creating and managing a custom network management server.
Along the way I have become certified as a MCSE, CCNP, CWNA, A+, Security+, and Network+.
I have been a Cisco Certified Network Professional since April of 2000.
I have been the lead engineer for various projects including IP Video utilizing Cisco IPTV, VBrick and Optibase multicast solutions. I have been involved in the acquisition and operations of Tandberg Video Teleconferencing solutions, and various other IP Video and Voice services.
Also I have developed a custom database repository and web based management platform which includes front end interfaces for many NMS tools and utilities including VOIP asset tracking, Wireless client reports, communication closet databases, UPS graphical statistics, dynamic network uplink utilization charts and weathermaps, and various other tools.
Our campus includes over 25,000 users, 1200 network devices and over 50,000 network interfaces. Our network control center has utilized a wide array of third party network management solutions including Cisco Works, SNMPc, HP Openview and others, however we continue to find that there is a major gap that needs to be filled by custom NMS software.
Along the way I have been self-taught in various programming languages mostly based around Perl on Windows Servers(due to security restrictions), SNMP, SQL, RRDTool, HTML and CSS.
In treading this path I have learned many things with the help of Google and the community of web based tutorials, wikis, forums, and the open source community. I have run into many problems and struggles but I have usually discovered the solutions, sometime with a simple search, but also at times a long hard battle. I have typically documented my findings in a notepad, through a saved document, or just in my head. Well as I get older and my filing system gets more and more cluttered I find it harder to recall this information at the time it is needed. Therefore I am starting this blog as a repository for the lessons I have learned. This will be a needed resource that I can return to for reference, but also I am hoping that I can save some frustration of others out there traveling down the roads of computer frustration!
Drop me a line or comment if this has been of any assistance to you.
And thanks to all those who have contributed to my progress through this crazy world of Information Technology and Communications.
Thanks,
Matt