Posted on 09-09-2013 08:45 AM
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.
Solved! Go to Solution.
Posted on 09-09-2013 09:07 AM
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"
Posted on 09-09-2013 08:47 AM
in a script -rf might be more helpful than an interactive -R
Posted on 09-09-2013 08:52 AM
Thx I should have mentioned that I was originally trying -rf and since it didn't work I tried -R also
Posted on 09-09-2013 09:07 AM
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"
Posted on 09-10-2013 01:06 AM
We have had many issues with scripts not running during imaging, we have to set them to run at reboot for them to work.
Posted on 09-10-2013 04:05 AM
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 :-)