APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Why I have to use Unix: scanning name tag badges

© July 2004 Tony Lawrence

Referencing: Unix vs. PC again

I had email from a client who needed to use handheld scanners to scan visitor badges and determine if the badge had already been used that day. I quickly came up with some protocode that would run against the device the scanner(s) were connected to.

It's not efficient code. It does a lot of opening and closing. Part of the reason for that is simplicity, and the other reason is that this was to be used in hostile territory where the power might die at any minute, etc - we wanted to write early, write often. There are better ways of doing that, too, but again, this was just a quick, ad-hoc solution.

Now yeah, you could do this on Windows, probably even with similar code. But my bet is you wouldn't. In fact, I bet if you had to do this on Windows, it would either never get done at all or cost you a pretty penny at least.

Now sure, part of the reason for that is that I know it can be done and know how to do it. If you happened to have a Windows person with similar talents, it wouldn't be a big deal. But my point is that the Windows customer wouldn't ordinarily think that this would be something they could write themselves. What devices does the scanner use? Who the heck knows, that's buried in the device driver. Will it even do multiple scanners? How do you conveniently tie Perl to the device(s)?

It just isn't as direct, and as I said, my bet is it just wouldn't get done. The client would go shopping for Windows Badge Scanning Software.Try a Google search for that and you'll see what I mean: most of it wants an NT Server, Oracle or Access, and $$$. And as is almost always true, it probably does much, much more than you need it to do. This client just wants to scan a badge number: she doesn't want to track leads, she doesn't want to buy a big NT server or Palm Pilots instead of scanners. She carries a cheap little Linux machine to the show, a little network switch (these are network connected scanners), runs multiple instances of this little script, and she has what she wants. If she needs to add features or make changes while at the show, well, it's just a Perl script: change it. That's another reason the code is simplistic: a less techy user may want to mess with it.

while (1) {
       $line = <>;
       exit 0 if $line =~ /quit/i;
       ($sec, $min, $hour, $mday, $mon, $year) = localtime($rightnow);
       # if it's after 3 PM it's "tomorrow"
       $rightnow += (24 * 3600) if $hour > 14;
      ($sec, $min, $hour, $mday, $mon, $year) = localtime($rightnow);

       #dbm files aren't multi-user safe so we lock


       $key = "$line $date";
       if ($db{$key}) {
          print "\007" .$line . "already in db $date";
       $db{$key} = "1";
       dbmclose %db;
       close LOCK;

That's all of it. You could add more features, like storing the full date and time instead of just a "1", or scanning information and storing it, and you could use the database after the show to make reports of vistors, etc. And the interface could be more user friendly, could be gui-fied, etc. But as it sits, she can connect her hand held scanners and get what she wants.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Why I have to use Unix: scanning name tag badges

1 comment

Inexpensive and informative Apple related e-books:

Take Control of the Mac Command Line with Terminal, Second Edition

Take Control of Parallels Desktop 12

Take Control of iCloud, Fifth Edition

Photos: A Take Control Crash Course

Take Control of Automating Your Mac

More Articles by © Tony Lawrence

"Why I have to use Unix: scanning name tag badges"

The title could have been "Why I have to avoid using Windows: scanning name tag badges."

This is a classic example of properly sizing the hammer to the nail. Or in naval terms, there is never any reason to deploy a battleship to sink a rowboat. Based upon exhaustive calculations carried out here at the Dinosaur Development Depot, if this had been done in Windows the program would have four times as big, 16 times as expensive and 256 times as bug-prone, an exponential relationship possible only with Windows.


---July 21, 2004


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

Getting information off the Internet is like taking a drink from a fire hydrant. (Mitchell Kapor)

Linux posts

Troubleshooting posts

This post tagged:





Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode