Need to use bat script in BigFix action script to un-install a software

Hi Team,
Hope we all are doing good!!
I am creating a fixlet to un-install a software using a bat script and have made the below shown fixlet, could you please suggest if this to be ‘ok’ if not then please suggest remediation on the below action script. Ty

// Using the batch script in BigFix action script to perofrm the un-installation of Atom software.
createfile until END_OF_FILE
DIR="/usr/EY_AtomBot-2.1/"
if [ -d "$DIR" ]; then
  # Remove old bot. #
  echo "Removing old bot from ${DIR}..."
  /etc/init.d/ATOMBOT stop
  chkconfig ATOMBOT disable
  rm -f /etc/init.d/ATOMBOT
  rm -rf /usr/EY_AtomBot-2.1
fi
END_OF_FILE

delete c:\temp\atom-uninstall.bat
move __createfile c:\temp\atom-uninstall.bat
wait atom-uninstal.bat

I think you may have confused Windows Batch scripting with Linux shell script.

ugh…my bad, let me get this corrected. Just corrected:-1:
//Shell to Action Script Conversion Utility
delete __appendfile

appendfile DIR="/usr/EY_AtomBot-2.1/"
appendfile if [ -d “$DIR” ]; then
appendfile # Remove old bot. #
appendfile echo "Removing old bot from ${DIR}…"
appendfile /etc/init.d/ATOMBOT stop
appendfile chkconfig ATOMBOT disable
appendfile rm -f /etc/init.d/ATOMBOT
appendfile rm -rf /usr/EY_AtomBot-2.1
appendfile
appendfile fi

//modify appendfile to allow execution
wait chmod 555 "{(client folder of current site as string) & “/__appendfile”}

//execute shell script as written
wait “{(client folder of current site as string) & “/__appendfile”}”

Would this be the right way of converting it to BigFix Action script for Linux servers? Please suggest. Ty

It looks like this is ActionScript generated by a converter utility, but I’m not familiar with it - is this a custom utility or something we provided?

In any case it looks mostly correct, except the first line of the shell script should reference the shell to use as interpreter - the first line should usually be

#!/bin/sh

And while the ‘wait’ command may work as written, on some platforms we may need to call the shell explicitly

wait /bin/sh "{(client folder of current site as string) & "/__appendfile"}"
1 Like

Thanks, Jason, for responding to it, I have the converter utility that I use to convert the shell scripts to BigFix action script :-
https://bigfix.me/content/shelltoaction
is this ‘ok’ to use?
I will get the first line changed and updated.

Oh, really cool utility. I hadn’t noticed it before.

Yeah, should be fine to use, it’s a pretty simple conversion from shell script to ActionScript.

1 Like

Will cause issues. It is going to think it is relevance substitution.

You will likely need to update it to

appendfile echo “Removing old bot from ${{DIR}…”

1 Like

I appended the last line as suggested but it is still failing on the same line:-1:

Not sure why it is still failing. Please suggest. Ty

I usually find it better to MOVE the script file to a tmp folder and run it from there. Most of our boxes won’t let me run scripts from inside the BES Client folders reliably.

Somewhere like /var/tmp

2 Likes

Thanks a Lot, it worked:-1:

Fixing the damn issue with bat file for windows:slight_smile: