Posted on 01-29-2018 07:48 AM
Hello,
Can anyone tell me why this script will not work when deployed through the JSS?
rm -Rf /Applications/Install macOS High Sierra.app
I've also tried:
rm -Rf "/Applications/Install macOS High Sierra.app"
When I run these commands in terminal, it works fine. When I push these commands as scripts through the JSS, they do nothing.
Any ideas?
Posted on 01-29-2018 07:55 AM
Why not use the Restricted Software option on the JSS, you can stop the app process as well as delete the app.
Posted on 01-29-2018 07:56 AM
Can't really see a reason why it wouldn't work. It looks right to me from here.
But can you try adding in the full path to rm, like /bin/rm
? It really shouldn't need that, but try it anyway.
Posted on 01-29-2018 08:05 AM
Can you post the entire script? Or are you using the Execute Command option on a policy?
Posted on 01-29-2018 08:35 AM
would it work if it was this way
rm -rf /Applications/"Install macOS High Sierra.app"
Posted on 01-29-2018 08:41 AM
@Cornoir I"m pushing the latest version of the installer to all of our machines. I want to remove any installers that may have been previously downloaded from the app store by users.
@mm2270 Will try that now.
@emily That is the entire script. I've tried both ways that I posted as a script. Have not tried running with Files and Process Execute Command. I kind of need it ran as a script so that I can run it before other actions without creating two policies.
Posted on 01-29-2018 08:44 AM
@jstine if it's a bash script you need to add #!/bin/bash
to the top of the script.
Posted on 01-29-2018 08:45 AM
I think you will need to edit the script to setup the beginning
#!/bin/sh
rm -rf /Applications/"Install macOS High Sierra.app"
exit
Posted on 01-29-2018 08:55 AM
Posted on 01-29-2018 08:58 AM
Posted on 01-29-2018 09:01 AM
is the policy giving you an error in the log? That may help to figure out the problem.
Posted on 01-29-2018 09:04 AM
Ah. So strangely enough, in the past, scripts without a shebang in them would work when run from the Jamf console. We actually had a few back in the day, and they never had a problem running interestingly enough. I assume, at least back then, that the console would read the script extension (.sh), and assume a bash script and execute it correctly. That may have changed with version 9 or 10 though. Especially now that scripts can be created directly in the web UI and don't need any extension.
I made an incorrect assumption that the script line was being added to the Execute Command field, not run as a full script, given it's a single line. Because as a single command in Execute Command, it would have worked as is.
Posted on 01-29-2018 09:04 AM
Removed.
Posted on 01-29-2018 09:06 AM
I think something might be wrong with our JSS. The logs show that the script isn't actually being run as a part of the policy.
Posted on 01-29-2018 09:11 AM
I would assume something is wrong with the policy first before assuming it's your whole Jamf Pro setup. Create a new policy and maybe even a new script and put them together and try it again.
And just a question, but, the policy IS running, correct? This isn't a case of the policy not running again because of the policy blackout window is it?
Posted on 01-29-2018 09:16 AM
@mm2270 Yes the policy is running. I completely deleted and recreated both the policy and the script. When looking at the logs, it does not actually run the script at all. I've opened a case with Jamf support and hope to hear something soon.
Thank you everyone for your help. I will post the resolution when I have it.
Posted on 01-29-2018 11:11 PM
We use this script:
sudo rm -rf "/Applications/Install macOS High Sierra.app"
Posted on 10-08-2018 11:12 AM
I am using a policy and under "Files and Processes" I am searching for file by path and checked delete if found. I think this was a user requested feature a few revs back.
Posted on 10-08-2018 02:17 PM
Maybe the script has an operating system requirement set in it's options, check the Limitations tab in the script editor.
You didn't copy another script to initially get started?
Posted on 10-09-2018 05:53 AM
#!/bin/sh
## set the name of the appication to remove
appName="/Applications/Install macOS High Sierra.app"
logFile="/private/var/log/TECHUninstalls.log"
log () {
/bin/echo $1
/bin/echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}
log "-----"
log "If found, will remove $appName..."
if [ -d "$appName" ]
then
/bin/rm -rf "$appName"
log "Removed $appName"
else
log "$appName wasn't there."
fi
Posted on 10-09-2018 06:30 AM
I'm not sure why it's necessary to remove the old installer, since any time I've pushed an updated version to clients it overwrites the old one.
Posted on 03-16-2023 11:25 AM
Sorry for the necromancy, but we're seeing users updating using old cached installers... I'd just nuke them all from orbit, but I worry about trying to delete the old one when it's being run.
Anyone have a good way to check if it's running at all before just deleting it?