Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have to step in and defend the shell,
Done right, the shell will give you great productivity, better than perl for many tasks

The trouble with the shell is is that programmers often forget structured programming. So one sees splats of shell done again and again to do simple things like file archiving, database access, file loads/unloads, ftps, error reporting, etc.

Any task with complicated programming should be wrapped - in perl, C, C++, or a carefully done shell script or function.

Any task done frequently should go to a library.

Error handling - you can catch any error - you needn't lose anything. But you must NOT redirect scripts' stdout and stderr, except at the topmost level of control. If you're starting processes in the background, their failure can be signalled by touching a defined file, since you can't reap their exit status. Simple but effective.

Meantime for foreground, errors are always sent back to caller in $?, same as perl.

If you have to produce a script for several platforms, perl might be better, I don't know, but this is a discipline in itself. I'm skeptical though.

ksh behaviour is standard - "echo" and "print" are defined. Korn shell 93 seems to be an attempt to do perl things, particularly hashes, which perl does much better.

If you have to migrate platforms, it is fairly easy, but retest - you'd have to do the same for perl.

Korn shell job control is wondrous compared with perl. Just start all your concurrent processes with & on the end, and then "wait" for them. This leads to very simple scripts that can efficiently run complex jobs with maximum concurrency of their different elements - very useful on our big RDBMS. Korn functions you start in the background, anonymous or named, can then further parallelise other tasks. Before you know it, and incredibly simply, you've got everything happening at once, and a 2 hours job is 10 mins. All the clever bits are in SQL, perl, C or whatever, with a couple of hundred lines of korn to glue it together.

Windows .bat files are contemptible. For all but tiny scripts, shell or perl seem essential. What's amusing is how managers intervene to prevent this, insisting on VB or some custom interpreter, produced because perl/shell are "not invented here".

We have a binary for executing SQL on the db in a simple manner, a shell script that wraps db bulk-load/unload effectively for our platform, and a couple of shell libraries to wrap, standardise, and de-skill things like ftp, errors and warnings, "ps" process checks, plus one or two other libraries and perl utils for larger, standardisable things

Kornshell isn't suitable for complex programs, but properly done, it can simplify, speed up and provide efficient glue.

Kornshell does need proper programming discipline.

Perl is still fantastic, but I find kornshell much better for these jobs, glueing utilities and libraries quicker and better than perl.

Incidentally it's perfectly easy to make similar mistakes in perl. A lot of our perl uses OO with too many inheritance levels - the code is so dense it's more like looking at COBOL - quite an achievement.

In reply to Re: Unix shell versus Perl by Abe
in thread Unix shell versus Perl by eyepopslikeamosquito

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (9)
    As of 2020-11-23 22:05 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found