Posts Tagged ‘linux’
New Blog Announcement – Shell Magic
I’m excited to say that I am working on a series of screencasts that target Unix command-line newbies. The series is called $hell Magic, and it’s my first attempt at making screencasts. It was a lot of fun and surprisingly simple to create my first one.
If you would like to learn more about the Unix or Linux command-line, or you know someone else who would, please feel free to check it out.
Stupid Unix Tricks – Creating A Self-Updating Dashboard
Have you ever wanted to automatically run the same command every 5, 10, or 60 seconds on a Unix/Linux machine until the output changed?
For example, let’s say that you’re deploying a new application on top of a Tomcat app server. After starting Tomcat and deploying your application, it can take a couple of minutes before the application is really available. However, you want to know exactly when the new version of the application is usable (give or take 10 seconds).
A good way of testing whether the application is really “up” is to ping a URL. You can do this using a web browser, but this approach has a few disadvantages. First, it’s a manual, tedious process. Second, web browsers can be a little flaky sometimes. For example, they may cache your last results, giving you incorrect results.
For me, I get much better results testing this sort of thing with curl. Here’s an example of how you could test the availability of the Hello World application that comes with Tomcat 6.x:
$ curl http://localhost:8080/examples/servlets/servlet/HelloWorldExample <html> <head> <title>Hello World!</title> </head> <body bgcolor="white"> <a href="../helloworld.html"> <img src="../images/code.gif" height=24 width=24 align=right border=0 alt="view code"></a> <a href="../index.html"> <img src="../images/return.gif" height=24 width=24 align=right border=0 alt="return"></a> <h1>Hello World!</h1> </body> </html>
This is fine, but it can also very labor-intensive and tedious to execute the same command over and over. Wouldn’t it be nice if we could just create an ad-hoc “dashboard” for this command?
Here’s how you can do it. All we have to do is a little shell magic:
$ while true; do curl http://localhost:8080/examples/servlets/servlet/HelloWorldExample; sleep 10; done
Here’s what I’m doing:
- First, I’m creating an infinite while loop. You’ll see why this isn’t a bad idea in a second.
- Next, I’m running our curl command.
- After that, I’m sleeping for 10 seconds. This is very important, because you don’t want to command to execute multiple times a second in an infinite loop.
This loop will repeat itself forever until you kill it with a Ctrl-C.
And here’s my results (assuming that I just restarted the server and it took that servlet 20 seconds to respond):
curl: (7) couldn't connect to host # First execution curl: (7) couldn't connect to host # second <html> # Success! <head> <title>Hello World!</title> </head> <body bgcolor="white"> <a href="../helloworld.html"> <img src="../images/code.gif" height=24 width=24 align=right border=0 alt="view code"></a> <a href="../index.html"> <img src="../images/return.gif" height=24 width=24 align=right border=0 alt="return"></a> <h1>Hello World!</h1> </body> </html>
Ta-da! Easy, automatic command testing. Of course, you can use this trick with commands other than curl. It’s very handy in any situation where you want to check a command for a change in output.
Notes On Installing Ubuntu 9.04 And Easy Peasy 1.5
It’s unlike me to upgrade my systems very often since it can take so much time, but I was moved recently to upgrade both my “server” (to Ubuntu 9.04) and my EEE PC 900 (to Easy Peasy 1.5). In general, I’m very impressed with how much better Linux-on-the-desktop gets every 6 months, and I look forward to at least another 8 years as a happy desktop Linux user.
One of the great things about Ubuntu is that it really is just painless to set up some pretty sophisticated servers. For example, I use my Ubuntu server to record television shows using MythTv, which can be very difficult to install. However, using the Ubuntu packages, I was able to get my system up-and-running in less than 10 minutes.
I do have one very small criticism of Ubuntu, and it’s that they keep making it harder and harder to install ffmpeg from source. The “stock” version of ffmpeg that comes with Ubuntu can’t do a lot of cool things like convert videos to the H264 format, so one of the first things that I usually do after installing Ubuntu is compile a more robust version of that application. Well, the process I used to compile it in 8.04 definitely did not work with 9.04 for some strange reason. Thank goodness that I found this tutorial, which made things very simple.
One really great thing about the 1.5 version of Easy Peasy is that I can now use some Compiz effects with my EEE PC 900. Previous versions of Easy Peasy didn’t even allow me to turn Compiz on. Hooray for tons tap-dancing sprites on my screen!
Here are some of the resources that I used to set up my Ubuntu 9.04 and Easy Peasy 1.5 systems. Maybe someone else will find them to be useful:
Bulk-Uploading Images To Snapfish On Linux
Snapfish is one of those web sites that I use a lot even though I hate it because it’s favored by most of my family. It’s interface seems to favor people who only use computers when they have to. Also, it doesn’t give you many sharing options compared photo sites such as Picasa Web, Flickr, or Photo Bucket.
The number 1 reason I don’t like Snapfish, however, is that they don’t have a decent bulk-uploaded that works on Linux. The one on Windows works very well, but since I’m in a Windows-free home, that’s not an option. You can upload up to 10 photos at a time after entering the path for each photo, but this is tedious and slow. For example, I wanted to upload about 45 pictures the other night, and it took me nearly 3 hours.
The good news is that I finally discovered a new way to easily upload more than 10 photos to Snapfish. Picasa 3.0 for Linux allows you to upload your photos to 14 different sites, including Snapfish. You simply choose the photos you want to upload using the Picasa application (the fat-client version, not the Picasa Web version), and then click on the Shop button at the bottom of the screen. Then simply choose your favorite photo developer from the list, log on, and Picasa will start uploading your photos. Sweet!
A few other nice things about the latest version of Picasa for Linux:
- There are installers for RPM-based distributions (like Red Hat and SuSE), Debian, and Ubuntu. I’m using Ubuntu 7.10 (which makes me behind by 2 major versions), and it installed quickly and easily.
- Picasa also allows you to upload to Walgreens and RitzPix. There are the only other photo developers that I use in addition to Snapfish, and I hate their native upload interfaces on Linux, so this is a nice bonus.
Even if you wouldn’t dream of using Picasa to manage your photos for some reason, if you use Linux and have ever complained about uploading your photos, you need to check it out. It’s worth the space on your hard drive, even if you’re just using it as a glorified photo uploader.
Update (8/26/09): Two strange things happened since I wrote this article. First, uploading to Snapfish from Picasa 3 seems to be broken. Second, if you have Flash 10 installed on your Linux machine, you can now bulk-upload photos to Snapfish using the Snapfish web site.
Cool GNU Screen Helper Functions
I’m a big fan of using GNU Screen, a terminal multiplexer. At any given time, I could be interacting with a dozen different Unix servers at work. I therefore group servers into logical, named groups and jump back and forth between them using screen.
I find the following one-liner functions to be incredibly helpful to me when it comes to managing multiple screen sessions simultaneously. Hopefully someone else will also benefit from them. I currently run these one-liners using the Bash shell, and store them in my ~/.bashrc file. Each function should be runnable from a shell prompt.
getscreenpids
function getscreenpids() { ps auxww | grep screen | grep -v grep | awk '{print $2}'; }
This function simply returns a list of process id’s (pid’s) for each screen process. This is nice info to have if you want to kill a screen session, since each session uses it’s own screen process.
clearscreen
function clearscreen() { for pid in $(getscreenpids); do kill -9 $pid; done; screen -wipe; }
This function kills every screen session into which I am logged. This is nice if things get flaky and I just want to kill all of my screen processes quickly.
killscreen
function killscreen() { screen -ls | grep $1 | awk '{print $1}' | cut -f1 -d. | xargs kill -9; screen -wipe; }
This function kills every screen session that uses the title that you pass as the first parameter. So if you have one or more screen sessions titled “envA”, and you pass that string to this function, all of those screen sessions will be killed.
Best Bookkeeping App On Linux
Well, it’s a new year, and what’s a new year without a “get your financial shtuff in order” resolution. Every year, I blame part of my bookkeeping incompetence on my favorite accounting app, GnuCash , so I’m usually looking for something newer and better every January. So here’s my options this year:
Choices
GnuCash
This is always what I come back to, so why even look, right?
- Advantages
- FOSS!
- The new 2.0 version is so much better than the previous 1.8 version from usability and stability perspectives.
- Fairly robust and intuitive
- The standard on Linux (did I mention that I’m a Linux user?)
- Will probably be around forever, so I don’t have to worry about being forced to convert all of my historical financial data to a new app any time soon.
- New budgeting interface!
- Tons of great reporting features
- Reporting API using a variant of Lisp. Now if only I knew how to program in Lisp
- Disadvantages
- Can still be a little flaky at times
- Only really installs easily on Linux. OS X and Windows users have a much more difficult time.
- Please note that you can install GnuCash on both Mac OS X and Windows. It’s just hard to do. Also, the Windows port of GnuCash is very new, and would be considered alpha software in my opinion.
- Since it’s a “real” accounting app, it may be more than I need, meaning that I sometimes have to deal with complexity that is unnecessary for my needs.
Quicken
This only runs on Linux is I use Crossover or Wine, and apparently it doesn’t run very well. The same thing is true with MS Money, so no thanks.
Wesabe
This is a online-only bookkeeping app with some cool folksonomy features and a slick, AJAX-y interface.
- Advantages
- Seems very easy-to-use, especially when it comes to budgeting and report-generating
- There’s a free version, but I don’t know if that will work for me.
- Multi-user: very easy for myself and my wife to use this app at the same time.
- Very collaborative, which is nice if you’re fairly ignorant about the world of personal finance.
- Disadvantages
- Seems to force you to use a very non-intuitive interface (if you’re used to apps like Quickbooks or Quicken).
- You can’t add new transactions manually – you have to download a qif file from your bank and upload it into Wesabe.
- You can’t use Expense accounts or categories in Wesabe, just “tags”. This, to me, is very non-intuitive.
- I spend a lot of time on a train each day, and I can’t use this app offline, so that’s a big disadvantage for me.
- Very limited reporting functionality.
- You can basically get three types of reports. This may be enough for most people, but seems a bit limiting to me.
Moneydance
This is a Quicken-like bookkeeping app that isn’t quite as bloated and can run on nearly any OS that supports Java.
- Advantages
- Will pretty much run on any OS.
- Fairly robust
- Seems to have a plugin architecture that is compatible with Java and Python. Nice!
- Disadvantages
- Not free (bad), but inexpensive (good!)
- The budgeting interface seems a bit overly-simplistic. I’m hesitant to switch to a new bookkeeping app if this particular feature doesn’t really wow me.
- How long will this non-FOSS app survive?
- Please note that you can export all of your data to a qif format, so it’s fairly portable, even if MoneyDance were to fold tomorrow.
Jgnash
http://jgnash.sourceforge.net/wiki/index.php
This seems to be someone’s copy of GnuCash, but with a simpler interface and written in Java.
- Advantages
- FOSS!
- Will pretty much run on any OS.
- Beanshell scripting interface, which is incredibly cool
- Stable and somewhat robust
- Disadvantages
- No budgeting module, which really is a show-stopper for me
- That’s really it. This is definitely my second choice.
Conclusion
In the end, you should choose a program that best compliments your bookkeeping process, not one that “just takes care of it automatically”. The latter type of applications often impose a process on you that, more often than not, doesn’t really “fit”. Ideally, you should be able to fulfill your process completely using pencil and paper; your bookkeeping app should simply make your process more efficient.
I’d love to therefore say that I have defined my bookkeeping process from A-Z and therefore can confidently choose one of the apps above, but my process is still a work-in-progress. So since I need to make a decision soon, I’ll go with the app that imposes the fewest constraints on my process while still making me more efficient that I would be otherwise. For me, that app is still GnuCash, although jGnash comes in a close second.
Update – 7/21/09
After trying to install the stable version of GnuCash for windows about 20 times, I finally just switched over to jGnash 2.0 and haven’t looked back. The interface has improved dramatically, and I find it to be much simpler and more stable than GnuCash.

