Help with scripting/!

farranvi
New Contributor II

We currently use Forcepoint DLP.
We have the go ahead to mass remove it from our Macs.
If I push the uninstall command via JAMF remote, wepsvc --uninstall , it works.
Plugging this in as a script also seems to work: Tis is the command I can push:
sudo wepsvc –uninstall

this is what I have in my web script that says command not found:

!/bin/sh

!/bin/bash

/usr/local/sbin/wepsvc --uninstall

exit 0

Ive tried it without a file path and with a ./usr...

I’ve set up a Policy to run the script for any machines checking in, but it’s not working, the log says command not found.

I’m new with Jamf adopt too script savvy, can anyone shed some insight?

9 REPLIES 9

mm2270
Legendary Contributor III

Not sure if it was intentional or a copy/paste error, but you have 2 shebangs at the start of your script, #!/bin/sh and #!/bin/bash Pick one or the other. You don't need both.
Also please enclose scripts in posts with three backtick marks on top and bottom (like so ``` ) to make sure it retains script formatting.
As for the command not found error, I've run into this from time to time, and its usually because of the full path to the binary not being in the script, but you're saying you also see it when you include the full path, so that doesn't really explain it.

Edit: Meant to also ask, how was the script created? What application? Or was it written directly into the script editing window in the web UI? Sometimes the command not found error is due to bad formatting adding to the script from a text editor not intended for writing scripts.

ShaunRMiller83
Contributor III

This may not be the issue at all.. but is there any reason you have two shebangs?

It may be looking at the first shebang as a script/command and the second as its own command. Thus command not found since the first one would be blank. Or another alternative theory is since you have two shebangs. It may be seeing the second shebang as a command. Which is can't find or execute.

Again this may totally way off base but may be worth a quick test.

Also what happens if you take that command and create a policy with it the last section when creating a policy (I think its called advanced) and add your command there and test it. I'm not in front of at the moment but that may also be a good test.

Hope this helps

-Shaun

farranvi
New Contributor II

Bad paste, I already removed a shebang

farranvi
New Contributor II

Wondering if I can get it done in here....0dc1fc49397d4e15a57a408d797f9701

mm2270
Legendary Contributor III

Yes, that's the suggestion that @ShaunRMiller83 made above. But you of course need to put in the entire command, /usr/local/sbin/wepsvc --uninstall
For a one line command like that, it might make sense to drop it in there and not do a full script. But it depends on what you're trying to do. If you wanted to include any logic and other stuff, while it can still be done somewhat in the Execute Command field, it gets unwieldy pretty quickly.

farranvi
New Contributor II

If I do that, I get this;
70f7437301cb4ddf97fce1db1ff0323a

ShaunRMiller83
Contributor III

Just an observation

in your previous screen grab you put a path in the field to search for was that intentional?

It appears your uninstall command is running the uninstall and then the policy is searching for the path.

mm2270
Legendary Contributor III

OK, so it's at this point that I would ask you verify the websvc binary is actually in the /usr/local/sbin/ location. Is it possible you're asking it to run something that isn't on the target machine? It sounds like it just can't locate that binary to me.

Tangentism
Contributor III

You can go to terminal and type:

which websvc

and it will give you a path