Re: is tcl a reasonable alternative to unix shell scripts?
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 7 Aug 2006 20:21:42 -0700
Charles Russell wrote:
For years I have been using Bourne shell scripts for housekeeping tasks
(archiving files, converting files, etc.) but this is a tricky and messy
way to do things. I've been wondering whether one of the scripting
languages may be a simpler way to write housekeeping utilities. The
simple lisp-like syntax of tcl appeals to me. I note that python and
ruby have equivalents to the unix "find" command, but I cannot find on
skimming the tcl documentation that it has a good set of tools for
manipulating the file system. Are they there? Would tcl scripts be
simpler and/or more readable than shell scripts for writing simple
utilities? Does anyone have an example handy, e.g. for an incremental
backup utility?
Jeff and Michael have made some good suggestions. I'd just like to
remind you that the "find" command is not normall part of your shell.
So just do in Tcl what you usually do in your shell script: execute the
find command!
# assigning result to a variable:
set x [exec find]
# parse result into a proper list and assign it to a variable:
set y [split [exec find] \n]
Generally, unless you're on a system where the regular unix commands
are completely built-in to the shell and not available as executables
(and I know some embedded systems where this is indeed the case), Tcl
can do anything shell scripts can do with a much cleaner syntax and a
much more powerful substitution engine. Not to mention that you also
get to use things which you normally can't do in a regular shell script
like opening a socket etc..
My suggestion is when in a hurry and you need to get the job done then
there is nothing wrong with using Tcl simply as a glue language to
execute regular Unix commands like the "find" example above. As you get
more comfortable with the Tcl core functions and extensions (you really
should install tcllib at the very least) you'll find the built in
functions much easier to work with and in some cases much more
powerful. But exec (and open) is your friend - use them to make the
learning curve as gentle as possible.
.
- Follow-Ups:
- Re: is tcl a reasonable alternative to unix shell scripts?
- From: Darren New
- Re: is tcl a reasonable alternative to unix shell scripts?
- From: Michael A. Cleverly
- Re: is tcl a reasonable alternative to unix shell scripts?
- References:
- is tcl a reasonable alternative to unix shell scripts?
- From: Charles Russell
- is tcl a reasonable alternative to unix shell scripts?
- Prev by Date: Re: Odd glob result with Tcl 8.4.13 and HP-UX 11.0
- Next by Date: Re: gets dangerous with sockets
- Previous by thread: Re: is tcl a reasonable alternative to unix shell scripts?
- Next by thread: Re: is tcl a reasonable alternative to unix shell scripts?
- Index(es):
Relevant Pages
|
|