Disabling Multiple Linux User Accounts

I have written a Bash script to disable users listed in a file. Originally I was going pre-populate a list and figure out how to get BF to push the list and the script to the /tmp directory, set the file to executable then run the script. However I was wondering is there a way that I can perform this task using actions directly from BF and just input the user names when set up the action. Just looking for some assistance in figuring out the best way to do this.

Played around with this for a bit… This works. A little sloppy, but it might help bring ideas:

//add files in tuples structure e.g. file1, file2, file3
//e.g. c:\A.txt, c:\B.txt, c:\C.txt
action parameter query “DeleteFiles” with description “Please enter the Files to Delete”

if {exist tuple string item 0 of parameter “DeleteFiles”}
delete {tuple string item 0 of parameter “DeleteFiles”}
endif

if {exist tuple string item 1 of parameter “DeleteFiles”}
delete {tuple string item 1 of parameter “DeleteFiles”}
endif

if {exist tuple string item 2 of parameter “DeleteFiles”}
delete {tuple string item 2 of parameter “DeleteFiles”}
endif

You might be able to use an action parameter such as this to create a createfile and use the return symbol instead of the ", ". So each username ends up on a separate line, then you can use a bash for loop.

Just a thought

Yeah the createfile is probably the way to go… take a look at this:

https://forum.bigfix.com/t/createfile-appendfile-carriage-return-help/22824/3

Just tested. This works. Enter usernames separated by ‘;’

delete _createfile
createfile until END

{concatenation “%0a” of (substrings separated by “;” of (parameter “DeleteFiles”))}
END

Then you can use a for loop for user deletion

I am getting this error in the Logs

“Command failed (Substitution failed while writing file) createfile until END (action:1814332)”

This is what I wrote up in the ActionScript:

createfile until END
action parameter query “username” with description “Enter your input. Follow EVERY entry with a ( ; ) semicolon.”
{concatenation “%0a” of (substrings separated by “;” of (parameter “username”))}
END

delete “/tmp/userlist.txt”
copy __createfile “tmp/userlist.txt”

My input was : user1;user2,user3;

I am still working on it but a 2nd set of eyes is always helpful.

You’ll need the ‘action parameter query’ command to come before ‘createfile’ starts.

Okay I made the correction but still failing. Could it be its not recognizing the symbols and substitution character? I am assuming “%0a” is the ASCII hex character so should I replace “;” with its ASCII hex equivalent?

action parameter query “username” with description “Enter your input. Follow EVERY entry with a ( ; ) semicolon.”
createfile until END
{concatenation “%0a” of (substrings separated by “;” of (parameter “username”))}
END

delete userlist.txt
move __createfile userlist.txt
move “userlist.txt” “/tmp/userlist.txt”

so should “;” be “%3B” ?

The error is still,
" Command succeeded action parameter query “username” with description “Enter your input. Follow EVERY entry with a ( ; ) semicolon.” (action:1814511)
Command failed (Substitution failed while writing file) createfile until END (action:1814511)"

Make sure you’re not using smart quotes. Substrings separated by “;” should be fine, you only have to use percent-encoding for unprintable characters or literal double quotes. %0a is the encoding for a newline character.

Are you doing this in the Console, or the Fixlet Debugger?

‘action parameter query’ doesn’t work in the Debugger (it needs the Console interface to prompt you to enter a value). If you’re testing, you’ll have to enter a value for the parameter directly in ActionScript instead