Casey Bralla on 23 Dec 2009 05:33:10 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Easy Bash Scripting Question


On Wednesday December 23, 2009 8:28:01 am bergman@merctech.com wrote:

Good point, Mark, but this script was just an example.  (My script is more 
complex and does a specific task unrelated to the question I was asking.)

BTW, what does "sudo rm /* -r" do?  <grin>

> 
> =>
> => for example:
> =>
> => #!/bin/bash
> => cp file1 file2
> => mkdir /directory1
> => cd /directory1
> => rm *
> 
> Whoa! That's very risky....think of what happens if the "mkdir" or "cd"
> commands fail. I've seen developers wipe out a multi-millon dollar
> ecommerce site multiple times with just this kind of error. (Yes, multiple
> times...they assumed it was an OS or sysadmin error, and after I restored
>  the server--multiple times--they kept running the same script...loads of
>  fun.)
> 
> Before running this script, I'd strongly recommend:
> 
> 	changing the "rm" command to echo what it would do, as in:
> 
> 		echo "Would do: rm *"
> 
> 
> 	learning how to check the return value of a command (the mkdir & cd),
> 	and how to avoid doing the following operations if the command[s]
> 	failed
> 
> Mark
> > 

-- 

Casey Bralla
Chief Nerd in Residence
The NerdWorld Organisation

http://www.NerdWorld.org
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug