General discussion
October 25, 2006 at 09:37 AM
danlm

sys utilities written in Perl versus shell scripts, which is better?

by danlm . Updated 19 years, 11 months ago

I’ve been putting together some system scripts for where I’m working right now on an OS X 10 system. They were specific in the request, but I coded them in a way to allow them to be general purpose. In other words, I wrote them to use config files.
Examples of these scripts:
– Shell Script – Monitor script to watch 3 java process’s to insure that they are always running, and if found not to be. Will launch them automatically. No pid numbers are used, just the name that appears in the ps -x. This was written for a specific application, but if you pull in the correct config file this script can monitor anything.
– Perl Script – Backup script that backups up directories to a zip file, and only retains so many of these backups. Deleting the oldest backup when the retention limit is reached. This really could be used for any directory, with any number of retention copies defined.
IE: cvsrespsrc-daily-20061024.zip keep 5 copies
cvsrespsrc-monthly-20061024.zip keep 10 copies.

I have everything running from corntab. In my eyes, the Perl script was cleaner. Lately, I have done everything in shell script because it was more universal. At least, I thought so. But, I’m sitting here thinking about this. Perl offers me so much more flexibility and is universal also.

Is there a reason to go with one and not the other? After my backup script, I’m almost tempted to use Perl for everything again. I can’t think of any strength’s that one really has over the other. Other then Perl is much more flexible. Is shell scripts less overhead because you are using os utilities for almost everything?

Dan

This discussion is locked

All Comments