Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Shell script for a moron

Thread Tools
 
Search this Thread
 
Old 05 July 2006, 09:22 PM
  #1  
Markus
Scooby Regular
Thread Starter
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default Shell script for a moron

Me iz fik, me not no how to rite sheel skripts (me talking like a troll too, mr shine, him diamond! )

I would like to do the following in a script
rm -rf /Library/FolderOne
rm -rf /Library/StartupItems/FolderTwo


That's easy. The bit I'm having issues with is this:

Find if /etc/mach_init.d/ directory exists. If it does then;
rm -rf /etc/mach_init.d/FileOne

If it's not there, do nothing. The final, and other problematic step is to then ask the user if they wish to delete a specific directory (/Users/UserFolderOne/) and if they answer 'y' delete it, if they answer 'n' don't delete it.

Anyone wish to help a fik troll speeking moron and show me how to do the above?
Old 05 July 2006, 10:38 PM
  #2  
jpor
Scooby Regular
iTrader: (1)
 
jpor's Avatar
 
Join Date: Sep 2003
Posts: 3,109
Likes: 0
Received 0 Likes on 0 Posts
Default

What about this:

DIR=/etc/mach_init.d

if [ -d ${DIR} ]
then
rm -rf /etc/mach_init.d/FileOne

else
error_exit "Unable to find ${DIR}"
sleep 3
fi

If you want them to add input:

DIR=/etc/mach_init.d

if [ -d ${DIR} ]
then
echo "Do you wish to delete ${DIR} [Y/N] : \c"
read REPLY
REPLY=`echo $REPLY | tr "a-z" "A-Z"`

if [ ${REPLY} = "Y" ]
then
rm -rf /etc/mach_init.d/FileOne
echo
echo "Directory ${DIR} now deleted"
sleep 3
else
echo
echo "Directory ${DIR} will no be deleted"
sleep 3
fi

else
error_exit "Unable to find ${DIR}"
sleep 3
fi

This has not been tested. Just something to go on.

Last edited by jpor; 05 July 2006 at 10:40 PM.
Old 06 July 2006, 12:01 AM
  #3  
Markus
Scooby Regular
Thread Starter
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

That'll do nicely. Thank you
Old 06 July 2006, 08:26 AM
  #4  
NotoriousREV
Scooby Regular
 
NotoriousREV's Avatar
 
Join Date: Jan 2002
Posts: 11,581
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by jpor
echo "Directory ${DIR} will no be deleted"
I guess this is SCOT-UNIX?
Old 06 July 2006, 02:07 PM
  #5  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Default

Duh, rm -i !!
Old 06 July 2006, 02:32 PM
  #6  
Markus
Scooby Regular
Thread Starter
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

ooh, hood point there Steve. sometimes I should probably read the man pages
Old 06 July 2006, 06:07 PM
  #7  
jpor
Scooby Regular
iTrader: (1)
 
jpor's Avatar
 
Join Date: Sep 2003
Posts: 3,109
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by NotoriousREV
I guess this is SCOT-UNIX?
Nope. KSH on AIX.

But I get you're point with the spelling.

Trending Topics

Old 06 July 2006, 06:11 PM
  #8  
jpor
Scooby Regular
iTrader: (1)
 
jpor's Avatar
 
Join Date: Sep 2003
Posts: 3,109
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by stevencotton
Duh, rm -i !!
Yes rm with interactive switch would also mean, you won't need the

echo "Do you wish to delete ${DIR} [Y/N] : \c"
read REPLY
REPLY=`echo $REPLY | tr "a-z" "A-Z"`

lines in the script.
Old 07 July 2006, 01:32 PM
  #9  
DrEvil
Scooby Regular
 
DrEvil's Avatar
 
Join Date: Oct 2000
Location: Surrey, UK
Posts: 8,384
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by stevencotton
Duh, rm -i !!
Give him a break, he's an AIX admin - lost with out smitty's F6 feature!

(btw, just finished my AIX cert )
Old 07 July 2006, 08:41 PM
  #10  
jpor
Scooby Regular
iTrader: (1)
 
jpor's Avatar
 
Join Date: Sep 2003
Posts: 3,109
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by DrEvil
Give him a break, he's an AIX admin - lost with out smitty's F6 feature!

(btw, just finished my AIX cert )
DrEvil. I am thinking of taking test 222 AIX sys admin exam in October this year. How did you find the exam? Any tips?
Old 08 July 2006, 12:11 AM
  #11  
GaryCat
Scooby Regular
 
GaryCat's Avatar
 
Join Date: Apr 1999
Posts: 2,043
Likes: 0
Received 0 Likes on 0 Posts
Default

Oh... I love Unix, all our stuff is on WIndows servers now. Where's grep and sed when you need 'em?
Old 08 July 2006, 08:23 PM
  #12  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

Gary,

Actually quite usefull http://unxutils.sourceforge.net/UnxUtils.zip

David
Old 08 July 2006, 08:34 PM
  #13  
J4CKO
Scooby Regular
iTrader: (1)
 
J4CKO's Avatar
 
Join Date: Jan 2003
Posts: 19,384
Likes: 0
Received 1 Like on 1 Post
Default

Just go to to the root drive, looged on as root and do rm -rf, that will get rid of any directories you ant to get rid of.....
Old 09 July 2006, 01:28 AM
  #14  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Default

Originally Posted by J4CKO
Just go to to the root drive
/: ?
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Abx
Subaru
22
09 January 2016 05:42 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
scoob1985
Wanted
0
13 September 2015 12:06 PM



Quick Reply: Shell script for a moron



All times are GMT +1. The time now is 02:14 PM.