Redirecting stdout and stderr in a batch file

One thing that I constantly need and can never remember the syntax for is redirecting stdout and stderr in a Windows batch file or cmd script (actually, the syntax is pretty much the same for *nix shell scripts).

Rather than just a one-sentence note here to remind me, I’ll write a few more sentences as explanation. Hopefully this will save someone a little bit of time

For starters, you can redirect the output of a command to a file like so:

blah.exe > output.txt

That example will overwrite any pre-existing output.txt file. If you want to append to the file, use:

blah.exe >> output.txt

But this only redirects “standard output” (stdout). If your program encounters an error, the output generated by the error condition probably won’t show up in the file. If you want it to show up in the file, redirect “standard error” (stderr) also like so:

blah.exe 2>&1 output.txt

At the moment, I can’t tell you if that will append or overwrite. I’ll check that out and update the post…

Temporary email addresses

You want to sign up for that free whitepaper on the Internet, but you don’t want your email address to end up on a dozen more mailing lists — what do you do?

Use a temporary email address. Mark Gibbs has a great article about them at NetworkWorld.com.

Of course, there are drawbacks. If everyone starts using these, the companies giving out free stuff will have to find another revenue model. Mark says he’s going to talk about the consequences in a future issue of his newsletter.

Installing Cacti on CentOS with yum

I’ve been wanting to try the Cacti network graphing system for a while, but wasn’t sure how much effort it would take. Well, it wasn’t too bad, and here are the steps that I used. Hopefully this will save someone else a few minutes.I started with the CentOS 4.3 Server CD. I really like having a single CD that will install what’s necessary for a server. I use the .iso and VMWare Server, and can have a server installed from scratch in very little time. For this server, I chose to customize the list of packages. I unchecked Mail Server, Windows File Server, DNS Name Server, FTP Server, and Printing Support. I added System Tools. I’ll assume that you have your OS installed at this point.

Configure yum. Since I want to use yum as much as possible, and cacti is not in the default CentOS repositories, I added Dag to my list of repositories. This is as simple as creating the file /etc/yum.repos.d/Dag.repo and putting the following in it:

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protect=0

That last option (“protect=0”) only does anything if you’ve installed the ProtectBase plugin for yum. This plugin keeps yum from updating system or base packages from non-CentOS repositories (or however you want to configure it). You can read about it here.

Continue reading

AI Roboform is awesome!

I recently started using Roboform for filling out forms online and logging into web sites and applications. Here’s a few of the things it does for me that I really like:

  • When I go to a web page that wants me to fill in contact information (name, address, email, age, sex, company name, etc), Roboform fills most of the fields in automatically. Plus, I can choose from various “identities”, like “Karl office” (which fills in my office email and mailing addresses) and “Karl personal” (which fills in personal info). All of this information is stored by Roboform on my computer in encrypted form, protected by a single master password (I have a long passphrase set). You set the timeout for the master password (2 hours is default).
  • Whenever I log into a web site (bank, library, tech support sites …), Roboform asks if I want it to save the name and password information in a “passcard”. These are also encrypted by the master password. From then on, whenever I go to those sites, the Roboform toolbar in IE and Firefox lets me login with a click. Roboform will also generate random passwords if you want it to for new logins that you’re creating.
  • Now when I want to login to any of those web apps, I don’t even need to open a browser. There’s a Roboform icon in the tray that will launch the browser, navigate to the site, and login. See the graphic below (which is edited to blank out private info). This is my favorite feature. I haven’t figured out how to tell it to launch IE for certain sites (Firefox is my default browser), so I launch IE first and then use the IE toolbar icon for sites that require IE.

Continue reading