TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    API call to list your commands on each computer

    General Discussion
    8
    3
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR
      Russ
      last edited by Russ

      @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

      Russell VanderMey

      1 Reply Last reply Reply Quote 1
      • E
        esaltat
        last edited by

        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!

        RussR 1 Reply Last reply Reply Quote 0
        • RussR
          Russ @esaltat
          last edited by Russ

          @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:
          258f7d6a-98cf-41a1-a032-8893ff3724c0-image.png

          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
          

          Russell VanderMey

          1 Reply Last reply Reply Quote 0
          • First post
            Last post