Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > why test ret-val of EACH cmd (example!):

Reply
Thread Tools

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

 
 
David Combs
Guest
Posts: n/a
 
      05-04-2005
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 50534 -- what next? [npq]
|

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

David


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
[exec cmd for cmd in cmds] =?ISO-8859-1?Q?Sch=FCle_Daniel?= Python 3 03-08-2006 03:21 PM
Interpreter-like help in cmd.Cmd Sarir Khamsi Python 4 06-26-2005 06:57 PM
read input for cmd.Cmd from file Achim Domma (Procoders) Python 2 06-03-2005 08:32 AM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57