The Scripting News

No, this isn’t a review of a new E. Annie Proulx book, or an homage to Dave Winer’s blog.

It’s just some notes on scripting.

In my home office, I run two main computers – one a Win2000 box, with SQL Server on it; the other a Linux (RH 7.3) box.

I also own two domains that are currently active (such as the one that this blog resides on); like my home setup, one is Win2000 (but with Access databases; I don’t need SQL right now [if the same price, I’d be on it in a minute, however] ) and the other a Unix-type box (Concentric has a proprietary Unix; seems to be BSD-based).

At home, I run different things on different boxes, and then I need to do the following tasks:

  • Move stuff from one home box to some remote server (one of my domains), or
  • Move stuff from one home box to the other home box, sometimes to dupe the environment to test for quirks (example: I run PHP and mySQL on both Linux [mainly] and Window [quirk testing] ), or just as backup in case the one box dies, the important stuff (databases, personal files etc) are backed up for at least 10 days).

In other words, I have to shuffle a lot of data around at various times. In our networked times, this is normal.

However, I’ll be the first to admit that this is not what I do best: My skills(?) are coding dynamic Web sites that bind well to the backend (databases) and have a user-friendly front-end.

Maybe someday I’ll be really good at it, but – today – I have done more than the average Web developer with this type of scripting, but I need to do more to be really good. Just a reality. (Of course, some people download and modify a Perl script and think they are scripting wizards, but that’s another story…)

What I’ve discovered:

  • Windows scripting sucks – Yeah, this sounds like a typical MS-is-Satan statement, but it’s just a reality. Now, I’m more adept at Linux admin than Windows admin (I guess…), but the Windows scripting components are so fragmented and primitive it hurts. Is there a way to script basic operations (i.e. not though apps, such as SQL Server) like file copies except via batch files (.bat)? Seems limiting, and – frankly – it is.
  • Linux built-ins rock – By built-ins, I mean the basic stuff that is usually there (tar) or those easily installed and free (zip, gzip etc). For Windows, I had to buy a license to the WinZip command line so I could use it in batch files. I didn’t really mind this – was inexpensive (~$30-35) and I was glad to give back to a company that I’ve used free tools from for….forever – but with Linux, that’s not a cost.
  • CRON vs. MS Scheduler – PUH-LEEZ! While Crontab is a command-line thing that a lot of people don’t like (a negative), and the MS Scheduler has an expire date option (a nice), Crontab is just soo much easier, faster and cleaner (to me). One drawback of the cron system is you have to learn it, and maybe the syntax for repeated tasks (every five minutes instead of at 12:05) is not a pull-down box, but you get there. Once you do, you don’t want to go back. I don’t.
  • Both batch and shell scripts are hard – Unlike HTML, for example, scripting is a more exact science, and is not as flexible. Both seem at least loosely based on C, and C is not forgiving and not terribly intuitive (until you understand it, when it becomes great). Again, I have not done that much scripting, and most that I have done is on the Linux side, so I’m more ignorant of the Windoze scripting stuff, but shell scripts (I use the Bash shell) seems far more powerful than the DOS shell. Again, could be my ignorance.
  • Bottom Line – I do as much scripting as possible on the Linux side. I have scheduled tasks on the Windows side (zipping directories for eventual move to Linux box; SQL Server daily backups…), but whenever the task involves both boxes, I put the load on Linux…because the load ends up lighter. For example: Each day, I export a SQL Server database to an Access database and then upload the Access database to my Windows-based domain. But I currently do the first part – SQL Server => Access – via Windows Scheduler. However, I then pull that Access database to my Linux box (for backup) and then FTP it to my remote Windows box (because it’s easier this way). I’m sure I’m missing something, but…