Skip to main content
Solved

Script for Removing User Folder

  • September 9, 2013
  • 5 replies
  • 0 views

Forum|alt.badge.img+22
  • Honored Contributor
  • 289 replies

Sorry total scripting newbie here. I am trying to remove a user folder via a shell script in Casper Imaging that used to work great in DeployStudio:
#!/bin/sh

rm -R /Macintosh HD/Users/apple

exit 0

I placed this .sh file in a config in Casper Admin, kick it off and the user folder is still there on reboot. has to be something in my syntax?

For a frame of reference what I am trying to to:
We lend users laptops with a local account on them, and then when the person returns the laptop, we wipe that user folder so the next person that uses the laptop doesn't see any of the previous web browsing history, files etc.

Best answer by mm2270

So, a few points.

First, I'm presuming from your post this would be running from an imaging setup where you won't be booted to the Macintosh HD. In that case, you need to include the full path, using /Volumes/, like this:

rm -rfd /Volumes/Macintosh HD/Users/apple

Second, Not sure if the above script lines are exactly what is in your script, but the backslash in the path to "Macintosh HD" needs a space after it, not before. You currently have

/Macintosh HD/

and, including the above point, it should be:

/Volumes/Macintosh HD/

Backslashes go before the character to be escaped, in this case a space. But... you could also just quote the whole path and not worry about spaces or other characters.

rm -rfd "/Volumes/Macintosh HD/Users/apple"
View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • September 9, 2013

in a script -rf might be more helpful than an interactive -R


Forum|alt.badge.img+22
  • Author
  • Honored Contributor
  • 289 replies
  • September 9, 2013

Thx I should have mentioned that I was originally trying -rf and since it didn't work I tried -R also


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7881 replies
  • Answer
  • September 9, 2013

So, a few points.

First, I'm presuming from your post this would be running from an imaging setup where you won't be booted to the Macintosh HD. In that case, you need to include the full path, using /Volumes/, like this:

rm -rfd /Volumes/Macintosh HD/Users/apple

Second, Not sure if the above script lines are exactly what is in your script, but the backslash in the path to "Macintosh HD" needs a space after it, not before. You currently have

/Macintosh HD/

and, including the above point, it should be:

/Volumes/Macintosh HD/

Backslashes go before the character to be escaped, in this case a space. But... you could also just quote the whole path and not worry about spaces or other characters.

rm -rfd "/Volumes/Macintosh HD/Users/apple"

Forum|alt.badge.img+7
  • Contributor
  • 48 replies
  • September 10, 2013

We have had many issues with scripts not running during imaging, we have to set them to run at reboot for them to work.


Forum|alt.badge.img+22
  • Author
  • Honored Contributor
  • 289 replies
  • September 10, 2013

Thx for all the detail on the full path! With your direction I see that I had a misplaced ""!

Script works perfectly now. really looking forward to gaining some scripting knowledge next month at JNUC :-)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings