4 Comments
- BladeMelbourne, on 10/12/2007, -0/+1For those interested in the original article and source: http://odetocode.com/Humor/68.aspx
(You can get Perl and VB.NET examples.)
Personally I prefer PHP - it's more portable and more succinct. Here's an example I wrote when the original HPHack link was posted.
function Comm($ip, $msg)
{
$fp = fsockopen($ip, 9100, $errno, $errstr, 5);
if (!$fp):
echo "$errstr ($errno)";
else:
fwrite($fp, "x1B%-12345X@PJL RDYMSG DISPLAY = "" . strtoupper(trim($msg)) . ""rnx1B%-12345Xrn");
echo "Sent "" . strtoupper(trim($msg)) . "" to " . $ip . ".";
flush();
fclose($fp);
endif;
}
function Status($ip)
{
$fp = fsockopen($ip, 9100, $errno, $errstr, 5);
if (!$fp):
echo "Possibly offline.";
else:
fwrite($fp, "x1B%-12345X@PJL INFO STATUSrnx1B%-12345Xrn");
$term = false;
while (!feof($fp) && !$term)
{
$string = fgets($fp, 128);
echo str_replace("n","",$string);
flush();
if (!(strpos($string, "ONLINE") === false))
{
$term = true;
}
}
fclose($fp);
endif;
} - DrunkenPirate, on 10/12/2007, -0/+0can't wait to do this at work
- bigronaldo, on 10/12/2007, -0/+0If the site goes down, here's another link to find it:
http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=7736e56d-6f90-4b21-ac93-d9b5f91a973f - egrabosky, on 10/12/2007, -0/+0lol +digg


What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the