Need to delete file using casper

mmichalek
New Contributor

I ma trying to delete a directory from /Library/Application Support/iLifeMediaBrowser

-Is there a way to accomplish this with jss. Do I need a script? If yet, does anyone have example?

6 REPLIES 6

Matt
Valued Contributor

Simple script will work

#!/bin/sh
rm -R "/yourdirectory"

Upload Script to Casper Admin
Create a Policy Set the target group
Set your trigger

mmichalek
New Contributor

not working
i get this error

/usr/sbin/jamf is version 8.6
Executing Policy Run Script iLifeFix.sh...
Creating directory structure for /Library/Application Support/JAMF/Downloads/
Downloading http://zeus.gowerschools.org:80/CasperShare/Scripts/iLifeFix.sh...
Running script iLifeFix.sh...
Script exit code: 2
Script result: /private/tmp/iLifeFix.sh: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found
/private/tmp/iLifeFix.sh: line 2: syntax error near unexpected token `}'
/private/tmp/iLifeFix.sh: line 2: `{fonttblf0fnilfcharset0 Calibri;f1fmodernfcharset0 Courier;}'

My script look like this:

#! /bin/sh
rm -rf "/Volumes/Macintosh_HD/Library/Application Support/iLifeMediaBrowser/"

tlarkin
Honored Contributor

Hi Everyone,

You can just run a command in a policy in the advanced tab to use the rm command to remove a directory. So, in the JSS, create a policy and have the policy do nothing, but on the advanced tab there is a run command box. In that box input your command. No script needed.

Just be careful you are doing the right thing as once you scope the policy to production there is no turning back.

Hope that helps,
Tom

mm2270
Legendary Contributor III

Your shebang is set up wrong if that is how your script actually looks. Should be

#!/bin/sh

You have a space in there.

But to make this easier, use either Casper Remote or a policy with the Run Command field under Advanced with something like-

rm -R /Library/Application Support/iLifeMediaBrowser

For one liners like that there is no need to create and upload a whole script.

tlarkin
Honored Contributor
My script look like this: #! /bin/sh rm -rf "/Volumes/Macintosh_HD/Library/Application Support/iLifeMediaBrowser/"

You have a space in your shebang, should be #!/bin/sh or #!/bin/bash

Hope this fixes your problem,
Tom

mmichalek
New Contributor

Thank You...I used the Run Command in the Advanced options. Works great