why test ret-val of EACH cmd (example!):

Discussion in 'Perl Misc' started by David Combs, May 4, 2005.

  1. David Combs

    David Combs Guest

    Just for use when warning people to test return-values,
    here's this post I just saw on comp.unix.solaris:


    | comp.unix.solaris #503931 (367 + 1662 more) | | \-(1)--(1)+-(1)
    | Newsgroups: comp.unix.programmer,comp.unix.solaris | | \-(1)
    | [1] Re: implicit -e in Solaris /bin/sh on cd? | \-(1)--(1)
    | From: Casper H.S. Dik <> \-(1)+-(1)
    | Date: Sat Apr 16 16:39:29 EDT 2005 |-(1)
    | Lines: 47 \-[1]
    |
    | Oscar del Rio <> writes:
    |
    | >Henry Townsend wrote:
    | >> % /bin/sh -c "cd /xxxx; /bin/pwd"
    | >> On Linux, this gives an error for the cd and thn proceeds to run
    | >> /bin/pwd (as it should IMHO):
    |
    | >not so good if the command is supposed to run in /xxxx, think of
    |
    | >cd /xxxx; rm -rf *
    |
    |
    | Indeed; one day a rather distraught Sun Service person turned up
    | at my desk, fearing that one of his customers systems had gotten hacked.
    | He brought with him a disk.
    |
    | I examined this disk; I was particularly worried about hacks because the
    | system didn't run anyting much at al, nothing from inetd anyway.
    |
    | Then I found that they had a ksh script which went as follows:
    |
    |
    |
    | for dir in <list of dirs>
    | do
    | cd $dir
    | find . -mtime -30 -exec rm {} \;
    | done
    |
    | Unfortunately, this was run as root, the first directory didn't
    | exist (had in fact been removed just prior to the incident) and
    | the find proceeded to remove all files until the point it removed
    | /usr/lib/ld.so.1; then it stopped removing stuff but rather started
    | logging errors.
    |
    | In the end I managed to recover the list of file printed by find
    | to tmpfs (/tmp/cron..*).
    |
    | It was a "ksh" script; had it been a "sh" script it would not
    | have failed in this manner.
    |
    | Casper
    | --
    | Expressed in this posting are my opinions. They are in no way related
    | to opinions held by my employer, Sun Microsystems.
    | Statements on Sun products included here are not gospel and may
    | be fiction rather than truth.
    | End of article 503931 (of 505348) -- what next? [npq]
    |

    (Now watch me go off and do that very thing!)

    David
    David Combs, May 4, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Guio
    Replies:
    6
    Views:
    3,190
    chris
    Oct 20, 2004
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,804
    Smokey Grindel
    Dec 2, 2006
  3. Holger
    Replies:
    11
    Views:
    545
    Gabriel Genellina
    Feb 12, 2007
  4. Michael Neumann

    "val.dup rescue val" sloooow

    Michael Neumann, Oct 27, 2004, in forum: Ruby
    Replies:
    2
    Views:
    132
    Michael Neumann
    Oct 27, 2004
  5. Anita Anita
    Replies:
    2
    Views:
    102
    Gary Wright
    Jan 6, 2009
Loading...

Share This Page