Darxus on Sun, 3 Sep 2000 18:55:47 -0400 (EDT) |
#!/usr/bin/perl # # CueUrl v0.5 released under the GPL. # Accepts output from a CueCat, prints the corresponding # Description and URL from the online database. # # Example: # # # ./cueurl.pl # .C3nZC3nZC3nXC3v3CNz2C3nX.aabI.y2nIy2eQ. # 1-piece alarm for use w/24-hour monitoring system # http://www.radioshack.com/Gateway/Detail/?P=4900351 # # .C3nZC3nZC3nXC3v3CNz2C3nX.fHmc.C3DZCxPWCNz2DNv7. # Catalog SKU # 6801913 # http://www.radioshack.com/Gateway/Detail/?P=6801913 # # 1st scan is a catalogue item, 2nd is the catalogue itself. use IO::Socket; $host = "a.dcnv.com"; while ($line = <STDIN>) { chomp $line; # Invert case. $line =~ tr/[a-z][A-Z]/[A-Z][a-z]/; # Connect to webserver. unless ($handle = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $host, PeerPort => '80')) { print "Failed to connect.\n"; } # Send query to webserver. print $handle "GET /CRQ/1..ACTIVATIONCODE.04".$line.".0 HTTP/1.0\r\n\r\n"; # Get response from webserver. recv($handle, $info, 2000, 0); # Split response into lines. @lines = split(/\r\n/,$info); foreach $retline (@lines) { ($var,$val) = split (/=/,$retline,2); if ($var eq "url" or $var eq "desc") { $$var = $val; } } print "$desc\n$url\n\n"; } ______________________________________________________________________ Philadelphia Linux Users Group - http://www.phillylinux.org Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce General Discussion - http://lists.phillylinux.org/mail/listinfo/plug
|
|