Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

WebDragon (1204)

WebDragon
  (email not shown publicly)
http://www.webdragon.net/

Macintosh owner/user since 1987
Perl hacker since 2000
Linux (Redhat/Fedora) user since 2001

Journal of WebDragon (1204)

Sunday March 30, 2003
01:40 AM

the joy and pain of refactored shell scripts.

[ #11310 ]

Well. My first Journal entry. I wonder what else is going to happen here... :-)

I've gotten somewhat frustrated with the quota warning system that comes with Red Hat 8, and after spending some time looking through the various quota modules and scripts on CPAN and having tracked down a quota_check.sh script from the web, that originated on Solaris, I've decided to go ahead and try and refactor it into Perl, to see what can be made of it.

Partially I'm doing this as an exercise, and to stretch my knowledge somewhat. I'm not a shell-scripter in the slightest so it's going to be interesting, to say the least. [I've already fallen for Randal's sh2perl joke. *sigh* That'll teach me not to read it first. :-)] Just trying to figure out why some of the things were done the way they were, as well as what some of the bizarre bash constructs even mean, is bad enough.

I can easily remove all of the stuff that uses awk, since Perl can do it all internally anyway. That's one hurdle that'll be fairly straightforward to resolve. The hard part is that it (the shell script) seems to have chain-loaded a rather large pipe sequence into a variable, in several different places in the script, all of which include awk and sub-scripts for it.

Separating out the wheat from the chaff and making it look clean and maintainable, making it scalable, and safe... is going to be the really hard part.

Some of the initial prep was fairly easy, thank goodness and little coders who whipped up Getopt::Long. Some of the wild shell case syntax was obviated thanks to this little gem.

Lord only knows where this is going to take me, how long it will take me, and whether or not ultimately it will be generally more useful and pragmatic than what already exists, but it'll be fun finding out. =:)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Long before the Acme namespace was mandated, there were a number of joke modules lurking around -- the lovely David H Adler esq's seminal Semi::Semicolons, for instance. Not certain, but I'm pretty sure sh2perl was the first (I heard an earlier incarnation of it emailed tchrist with a request to convert a shell script to perl).

    --
    /-\