API call to list your commands on each computer
-
@davboc asked me for a way to produce a list of his commands. I gave him an API call to use, and he came up with this python script that takes the output and makes it nice and readable. I thought it was pretty cool so I'm sharing it here:
import subprocess string=subprocess.check_output(["curl -k -X POST https://www.triggercmd.com/api/command/commandlist -H 'Authorization: Bearer (your token from Instructions page)'"],stderr=subprocess.STDOUT,shell=True).strip() array=string.decode().split('"name":') array.pop(0); for a in array: print a.split('"')[1].strip()
The output looks like this:
Downstairs > Calculator
Downstairs > Delete browse history
Downstairs > Launch a website
Downstairs > Notepad
Downstairs > Rebooting in 10 seconds
Downstairs > Volume Down
Downstairs > Volume Up
Garage > Betsy Garage Door
Garage > Reboot
Garage > Russ Garage Door
Garage > apt update
Garage > boot russfam
Laptop > Calculator
Laptop > Delete browse history in Internet Explorer
Laptop > Down Arrow
Laptop > Email my document list
Laptop > Launch a website
Laptop > Lock my PC
Laptop > Play mp3's in your Music folder
Laptop > Reboot
Laptop > Update Windows
MintNAS > Gnome Editor
MintNAS > Reboot
MintNAS > apt update
MintNAS > yum update
RussFam > Backup Documents
RussFam > Calculator
RussFam > Dropbox
RussFam > Email my document list
RussFam > Michael Jackson Thriller Album
RussFam > Mute -
Could I also ask for an API call to list (commands that was ran successfully / failed) with date stamp? That would be useful for me
Thanks!
-
@esaltat, in Linux you could use a command like this:
curl 'https://triggercmd.com/api/run/list?&sortOn=createdAt,DESC&command_id=(your command id)&token=(your token)'
You'll see your command id in your browser URL when you click the View Runs button for that command:
Or install jq and use this command will show two fields you're interested in:
curl 'https://triggercmd.com/api/run/list?&sortOn=createdAt,DESC&command_id=(your command id)&token=(your token)' | jq -r '.records[] | .createdAt + " " + .status' 2022-01-23T18:38:03.008Z Command ran 2022-01-23T18:38:02.844Z Trigger sent from website 2022-01-22T19:34:41.879Z Command ran 2022-01-22T19:34:40.150Z Trigger sent from Google Assistant Smart Home params = on 2022-01-15T16:38:46.310Z Command ran 2022-01-15T16:38:46.067Z Trigger sent from Google Assistant Smart Home params = on 2022-01-15T16:38:39.210Z Command ran 2022-01-15T16:38:38.205Z Trigger sent from Alexa Smart Home params = on 2022-01-15T16:18:52.395Z Command ran 2022-01-15T16:18:52.274Z Trigger sent from Alexa