Help with script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
01-26-2017
08:00 AM
- last edited on
03-04-2025
07:12 AM
by
kh-richa_mig
I am trying to run a script to remove an app from our Macs. When I run it, the killall lines work and the rm -r lines do not. The error I get is, "No such file or directory". If I run any of the commands alone in Terminal, they all work. Any ideas what I am doing wrong?
Here is the script:
!/bin/sh
sudo killall EquitracLoginController
sudo killall EQLoginController
sudo rm -r /Applications/Utilities/EquitracPrinterUtilityX.app
sudo rm -r /Library/Printers/Equitrac/
sudo rm -r /Library/Application Support/Equitrac/
- Labels:
-
Jamf Pro

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 08:23 AM
Without being on the computer, it's hard to troubleshoot. But, if you're running the script from the JSS, you don't need sudo, as everything runs as root. It may be breaking because it's expecting you to authenticate.
If you're installing Equitrac as a package, from Casper Imaging or Self Service, you could index the package, then check the Allow package to be uninstalled box. That might be a more complete deletion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 08:58 AM
At this point, I am just testing the script in the Terminal on a machine that has items listed in the directories targeted in lines 3-5.
Are you suggesting that I remove sudo and attempt running the script from the JSS?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 09:07 AM
Either that, or get rid of the sudos in the script, and use sudo to run the script itself.
As quoted from askubuntu:
It is rarely a good idea to have sudo inside scripts. Instead, remove the sudo from the script and run the script itself with sudo:
sudo myscript.sh
That way, all commands within the script will be run with root privileges and you only need to give the password once when launching the script.
Bonus tidbit: If you need a particular command within the script to be run without sudo privileges, you can run it as a regular user:
sudo -u username command

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 09:09 AM
So, your script should be:
#!/bin/sh
killall EquitracLoginController
killall EQLoginController
rm -r /Applications/Utilities/EquitracPrinterUtilityX.app
rm -r /Library/Printers/Equitrac/
rm -r /Library/Application Support/Equitrac/
exit 0
Then just run it with:
sudo sh ./dieEquitracDie.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 09:37 AM
Thanks. I tried your script version and I still get the "No such file or directory" error.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 09:41 AM
The error is originating here:
sudo rm -r /Library/Application Support/Equitrac/
The interpreter is reading that line as sudo rm -r /Library/Application
.
Assuming you've followed JayDuff's instructions re: sudo
, you'll want to change the above line to either:
rm -r /Library/Application Support/Equitrac
or
rm -r "/Library/Application Support/Equitrac"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 09:44 AM
Duh. Good spot, @grepoli !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 10:19 AM
Thanks @grepoli!
Using the same suggestion, I am unable to execute this line:
rm -r /Applications/Utilities/EquitracPrinterUtilityX.app
How should I handle that line?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 10:34 AM
Assuming you're running this script multiple times on the same computer, that file was already deleted the last time you ran the script during testing. Without the force (-f
) option, the rm
command fails when it encounters a nonexistent file/directory. Add that option, and for peace of mind, add the verbose (-v
) option as well.
Thus:
#!/usr/bin/env bash
# Kill processes if running
killall EquitracLoginController EQLoginController
# Remove the app and installed components
rm -rfv "/Applications/Utilities/EquitracPrinterUtilityX.app"
rm -rfv "/Library/Printers/Equitrac"
rm -rfv "/Library/Application Support/Equitrac"
sudo chmod +x /path/to/script
to make it executable, then run with sudo /path/to/script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-26-2017 01:27 PM
Thanks for all the help! Everything is working.
