Warning: imagecreatefromstring() [function.imagecreatefromstring]: Empty string or invalid image in /var/www/vhosts/tachytelic.net/httpdocs/wp-includes/media.php on line 258

Archive for Technical Posts

HP Direct PDF printing is a great cross platform driverless printing mechanism which I have used for a number of customers with great results.

A common problem with Direct PDF printing is that it is not possible to include any printer control commands such as tray calls within the PDF and lots of people have been asking how to do this – I checked with HP Technical support and was told it is not possible.

It is possible however to setup a print job with PJL commands and include the PDF documents within that job. The key being to set the printer language/personality to PDF and then using the UEL (Universal Exit Language) command to issue more control commands. After a bit of trial and error I found that this is actually quite straightforward, and thought I would post the code as I was not able to find any working examples:


ESC%-12345X@PJL
@PJL JOB NAME = "paultest2.pdf" DISPLAY = "Printing & Stapling paultest2.pdf"
@PJL SET OUTBIN=OPTIONALOUTBIN1
@PJL SET PROCESSINGTYPE="STAPLING"
@PJL SET PROCESSINGOPTION="LEFT_1PT_ANGLED"
@PJL SET MEDIASOURCE = TRAY3
@PJL ENTER LANGUAGE = PDF

After setting up the job with the above, you can then add the PDF code. After the PDF you either need to end the job or specify more further printing control. In my example I am printing another PDF document right away within the same job but from a different tray, like so:


ESC%-12345X@PJL
@PJL SET MEDIASOURCE = TRAY4
@PJL ENTER LANGUAGE = PDF

Then follow this with more PDF data and then end the job like this:


ESC%-12345X@PJL
@PJL RESET
@PJL EOJ NAME = "paultest2.pdf"
ESC%-12345X

In this example the two PDFs are also being stapled together and the status display on the printer is also updated to show what document is being printed.

All of the above was tested using a HP Laserjet P4015N with a 500-Sheet Stapler/Stacker(CB522A). Although it contains no references to PDF printing, the best reference I have found is this document from HP:

http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13208/bpl13208.pdf

In production I am doing all of the PJL wrapping via a korn shell script which I’ve tested from IBM AIX, Ubuntu and Sco Openserver 5.0.7.

Categories : How To, Technical Posts
Comments (14)

Earlier this year I posted a script which sends email alerts from Dell servers using the alerting system built into Dell Openmanage. However, that script will only work on Windows systems.

A visitor to the blog called Steve has kindly posted some code on that post which enables the same functionality in Linux and I think it is worthy of its own post.

Before attempting to use the script you will need to download this perl script called sendEmail and that you have unix2dos installed.

The script accepts two arguments, which are setup or show.

“setup” will set the alerts action to the value of $alert_script which should be the full path to the script itself.
“show” will print the current alert settings for the system to the screen.

The code of the script is as follows, or you can download from here:


#!/usr/bin/perl
########
#
# Alter these setting to suit your system
$alert_script='/opt/asx_scripts/send_alert.pl';
$argument = 0;
$argument = $ARGV[0];
$omreport = '/opt/dell/srvadmin/bin/omreport';
$omconfig = '/opt/dell/srvadmin/bin/omconfig';
$sendemail = '/opt/asx_scripts/sendEmail';
$toname = 'name';
$fromname = 'name';
$domain = 'domain.com';
$tmp_path = '/tmp';
$mail_gateway = 'ip or name of mailgate';
$unix2dos = '/usr/bin/unix2dos';
#
#

if("$argument" eq "setup"){
set_available_alerts();
exit;
}
if("$argument" eq "show"){
display_set_alerts();
exit;
}
if("$argument" eq "help"){
print "If you need some help read the code\n";
exit;
}
unless($argument){
$desc=`$omreport system alertlog 2>/dev/null | grep "Description" | head -1 | cut -f2-9 -d: | sed 's/ //'`;
chomp($desc);
$date=`$omreport system alertlog 2>/dev/null | grep "Date and Time" | head -1 | cut -f2-9 -d: | sed 's/ //g' | sed 's/://g'`;
chomp($date);
$host=`$omreport system summary 2>/dev/null | grep "Host Name" | head -1 | cut -f2-9 -d: | sed 's/ //'`;
chomp($host);
$tag=`$omreport system summary 2>/dev/null | grep "Chassis Service Tag" | head -1 | cut -f2-9 -d: | sed 's/ //'`;
chomp($tag);
$attach="$tmp_path/$date.log";
`$omreport system alertlog > "$attach"`;
if( -f "$unix2dos"){
`$unix2dos "$attach" 2>/dev/null`;
}
$send=`$sendemail -f "$fromname\@$domain" -t "$toname\@$domain" -u "System Error: $host SvcTag: $tag Time: $date" -m "$host SvcTag: $tag Error: $desc Time: $date" -a "$attach" -s "$mail_gateway"`;
}else{
print "If you need some help read the code\n";
exit;
}

sub set_available_alerts {
$alert_list = `$omconfig system alertaction 2>/dev/null | cut -f2 -d"<" | cut -f1 -d">"`;
chomp($alert_list);
chomp($alert_list);
@split_alert_list = split(/\|/, $alert_list);
foreach my $alert (@split_alert_list){
$set_result = `$omconfig system alertaction event=$alert execappath="$alert_script" 2>/dev/null | head -1`;
chomp($set_result);
if("$set_result" eq "Alert action(s) configured successfully."){
print "Set Action:\t$alert\n";
}else{
print "ERROR Set didnt return expected value ($set_result)\n";
}
}
}
sub display_set_alerts {
$currently_set = `$omreport system alertaction`;
print "$currently_set\n";
}

exit;

A good way to test the script is to temporarily set the “Temperature Maximum” to something low like 12 to trigger an alert.

Unfortunately all of my Linux machines are virtual machines so I cannot test or modify this script, so if anyone wants to give me SSH access to a server running OMSA, be my guest. :)

Again, big thanks to Steve for posting this and I am sure it will be useful to lots of people. This has also inspired me to make some improvements to my original Windows version.

Comments (24)

Today I was trying to use clnpack.exe fom a command line to automatically create updated installation packages for Trend Officescan on a weekly basis.  This seemed a simple case of putting together a command line but I wasn’t having any luck getting it working.

Annoyingly clnpack.exe does not give any error messages at all if the syntax of the commad is not perfect and you get nowhere.  In the end I discovered that I could only make clnpack.exe work by using 8.3 file paths instead of long path names.

An example of a working command line:


C:\PROGRA~1\TRENDM~1\OfficeScan\PCCSRV\Admin\Utility\ClientPackager\clnpack.exe /i /o NT /s C:\PROGRA~1\TRENDM~1\OfficeScan\PCCSRV /d d:\shared~1\software\trend32.exe

You can see 8.3 format filenames by going into a command prompt and using:

dir /x

Now that I have this command working I can integrate it with a batch file which will upload it to our web server.

Categories : Technical Posts
Comments (0)

This is a script that I posted to the Draytek forum a couple of years ago, I noticed that it has been a very popular post so I have decided to post here also.

The function of the script is to perform scheduled reboots of Draytek routers.  Optionally is it possible to reboot the router only if a specified IP address does not respond to a ping request.  This is useful to test if a VPN connection is functioning, and only reboot the router if there is no response.

Early Draytek firmwares had a tendancy to lose VPN connectivity and a reboot is the only way to restore the connection.

First of you need to install the Toolsack Baseline components for this script to work:

http://www.toolsack.com/download/

The script needs to be supplied with parameters, so a typical command line would look like this:

cscript reboot.vbs 86.11.93.131 routerpassword

and a conditional command line would look like this:

cscript reboot.vbs 86.11.93.131 routerpassword 192.168.1.254

The 3rd argument will be tested for a ping response, if none is received then a reboot will be executed.

Here is the code, save it as reboot.vbs:

set args=wscript.arguments

If wscript.arguments.count=2 then
   IP=args.item(0)
   Password=args.item(1)
   call reboot(IP,Password)
elseif wscript.arguments.count=3 then
   IP=args.item(0)
   Password=args.item(1)
   TestIP=args.item(2)
   if ping(TestIP)=False then
      call reboot(IP,Password)
   end if
else
   wscript.echo "Invalid number of arguments specified"
   wscript.echo "Please specify router IP address & password and optional test IP"
end if

sub reboot(IP, Password)
   set s = CreateObject("Toolsack.Socket")
   s.Connect IP, 23
       s.Write Password & vbCrLf
   s.write "sys reboot" & vbcrlf
   s.write "quit" & vbcrlf
end sub

Function Ping(strHost)

    dim objPing, objRetStatus

    set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
      ("select * from Win32_PingStatus where address = '" & strHost & "'")

    for each objRetStatus in objPing
        if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
       Ping = False
        else
            Ping = True
        end if
    next
End Function 
Comments (0)