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

    Linux VM - TriggerCMD shows messages like it's working, but commands don't actually execute

    General Discussion
    2
    33
    2.7k
    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.
    • J
      Joe
      last edited by

      Hello!

      As per the attached image, I appear to have TriggerCMD working on a Linux VM -- including TriggerCMD giving me satisfying messages in the terminal window. However, the given action doesn't actually execute.

      In the example below, I have a very simple shell script that appends "Hello World" to a file -- xxxx.txt. When I summon the script via Alexa, I get a message that suggests that it ran:

      $ { trigger: 'hello world', id: '5ec1f4d3c65a9d001992532f' }

      but as you can see nothing was added to xxxx.txt by this. However, when I run this script manually, it works.

      Note that both the default gedit opening example -- and a separate Gnome Calculator example I setup myself -- both exhibit the same behavior: I get a message from TriggerCMD in the terminal, but nothing happens.

      In case you can't read it in the attached image of the terminal, here is the root JSON file:

      $ sudo more /root/.TRIGGERcmdData/commands.json
      [
      {"trigger":"Gnome Editor","command":"gedit","ground":"background","voice":"edit","allowParams": "false"},
      {"trigger":"Gnome Calculator","command":"gnome-calculator","ground":"background","voice":"calculator","allowParams": "false"},
      {"trigger":"hello world","command":"/home/jhupcey/hello_world.sh","ground":"background","voice":"hello world","allowParams": "false"}
      ]

      And here is uname -a of the Linux install:
      $ uname -a
      Linux orw-mobile-vm 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Aug 25 11:21:22 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

      where "orw-mobile-vm" is the name of the VM instance.

      I'm sooooo close to getting this working -- what am I missing?

      Help!!!

      Joe

      triggercmd-linux-issue.JPG

      1 Reply Last reply Reply Quote 0
      • J
        Joe
        last edited by

        Edited to add:

        I have also tried making the triggers "foreground" as well as "background" -- no dice either way.

        Help!!!

        Joe

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

          @Joe, I'll get back to you after about 5pm EST. I wonder if you have a different commands.json in root's home folder vs. yours, and you're running the agent as you which would pick up your own ~/TRIGGERcmdData/commands.json.

          Russell VanderMey

          J 1 Reply Last reply Reply Quote 0
          • J
            Joe @Russ
            last edited by

            Thanks, @Russ!

            NP on the reply ETA

            In the meantime, toward your initial thought:
            As an experiment I just copied the root commands.json over the local commands.json (they were different - I didn't have the calc in the local one) and "called" hello_world.sh again -- no change in behavior.

            (For reference, this begs the question: Does the agent need to be restarted somehow to pickup on any changes like this because it caches the commands.json, or does it do a fresh re-read of the commands.json every time a command is run?)

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

              @Joe, the agent notices any time the commands.json file changes, and it automatically reads it and sends any trigger changes to the servers in the cloud.

              I bet if you run this command, you'll find your xxxx.txt file:

              find / | grep xxxx
              

              I setup my own script just like yours and found mine here:
              /usr/share/triggercmdagent/app/src/xxxx.txt

              You can fix that by changing your hello_world.sh script to be something like this:

              #!/bin/bash
              echo Hello World >> /tmp/xxxx.txt
              

              The working directory is not your home directory. It's the directory where the agent.js script lives.

              Also FYI, this isn't a problem, but I see you're escaping your forward slashes. You don't have to escape forward slashes - only backslashes. I probably confused people with that because I have some examples where I escape my forward slashes...

              Russell VanderMey

              J 1 Reply Last reply Reply Quote 0
              • J
                Joe @Russ
                last edited by

                @Russ indeed, the output of hello_world.txt is where you said it would be! Thanks!!!

                Now back to gedit and gnome-calculator:
                Neither the default gedit opening example or the Gnome Calculator example I setup myself are coming up -- I get a message from TriggerCMD in the terminal, but nothing happens. Any ideas?

                J 1 Reply Last reply Reply Quote 0
                • J
                  Joe @Joe
                  last edited by Joe

                  @Russ follow-up question on hello_world.sh:

                  When I set the appending to a "hard" directory like /tmp, it works fine

                  When I point it to my automounted home area path a-la:

                  #!/bin/bash
                  echo Hello World >> /home/<my_user_name>/xxxx.txt
                  

                  nothing happens and/or xxxx.txt doesn't seem to land anywhere.

                  Does agent.js / TriggerCMD not like automounted directories?

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

                    @Joe, about the automounted directory, is it available to root? I ask because I suspect your background service is running as root. I see from your commands.json file in your screenshot that all of your commands are set to background, so they would only run in the context of your background service.

                    In fact that's probably why you're not seeing those gnome apps. For those to run and be viewable, you'd need to run the agent in an X terminal in foreground mode (which is the default mode if you just run triggercmdagent). And, your commands would have to be foreground commands.

                    The agent running in one mode won't run commands that are set to run in the other mode. It will log when you trigger them though.

                    Another thing to consider. If you run the agent as a different user, it will create a new computer in your account because if it doesn't find a ~/.TRIGGERcmdData folder, it creates one with a fresh computer ID and creates the computer in your account with that ID. You could get around that by copying your .TRIGGERcmdData folder from /root to your user's home folder so it would connect with the same computer ID.

                    If your automounted home folders are available to root, then your hello world script should be able to write to those home folders with the background service running as root.

                    You probably know this, but you can switch to root with this command, then do an ls to see if you can see those home folders:

                    sudo su -
                    

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • J
                      Joe
                      last edited by

                      Thanks for the detailed update, @Russ !!!

                      A) I do now see the "fresh" xxxx.txt in the /root directory after a "sudo su -"

                      B ) Doesn't triggercmdagent need to be run as root (certainly it seemed to be a requirement for the install)? If not / presuming your comment on "you'd need to run the agent in an X terminal in foreground mode" means "no root, just run triggercmdagent as 'yourself'", I get this error when I try to run triggercmdagent as me in my home directory:

                      [jhupcey@orw-mobile-vm ~]$ 
                      [jhupcey@orw-mobile-vm ~]$ triggercmdagent &
                      [1] 19056
                      [jhupcey@orw-mobile-vm ~]$ /usr/share/triggercmdagent/triggercmdagent: symbol lookup error: /usr/share/triggercmdagent/triggercmdagent: undefined symbol: gtk_widget_get_scale_factor
                      
                      [1]    Exit 127                      triggercmdagent
                      [jhupcey@orw-mobile-vm ~]$
                      

                      C) A parallel interpretation of your above comment was to also:
                      C.1 -- As root/sudo: edit root's commands.json to make gedit and calc be "foreground"
                      C.2 -- As me, do a cut&paste of this revises commands.json into a vi editor, "copy" root's commands.json to /home/<my_user_name>/.TRIGGERcmdData directory so the "new" commands.json will clearly be in my personal account ownership
                      C.3 -- Expect that triggercmdagent will pickup on this new, "local" overlay

                      This yielded no change in behavior (I got the encouraging trigger message but still no calc popping up), and this I freely acknowledge I am still not getting it unfortunately.

                      D) How should I proceed? Do some sort of uninstall, re-install, edit some config file, or what? Help!

                      Joe

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

                        @Joe, why did you add a & to the end of the triggercmdagent command? If you leave that off, it should run the agent in foreground mode and you'll be able to see the output.

                        Please try running triggercmdagent in an xterm window as yourself, and trigger your foreground commands on the computer in your account that got created when you ran it as yourself (not the one created when you ran it as root).

                        If you want to start from scratch, there's no need to re-install. Just delete the ~/.TRIGGERcmdData folder, and the computer in your account that matches the ID in ~/.TRIGGERcmdData/computerid.cfg. Then when you run triggercmdagent, it will prompt you again for your token, then create a new computer and .TRIGGERcmdData folder.

                        Russell VanderMey

                        1 Reply Last reply Reply Quote 0
                        • J
                          Joe
                          last edited by

                          Regarding:
                          why did you add a & to the end of the triggercmdagent command?

                          Force of habit. Apologies.

                          Looking to start from scratch per your guidelines:

                          • I deleted the ~/.TRIGGERcmdData folder in my home area

                          • I also went my https://www.triggercmd.com/user/computer/list and deleted the Linux VM I'd been working with

                          • Next, I run % triggercmdagent in the foreground, but I get the following error almost immediately:

                          [jhupcey@orw-mobile-vm ~]$ triggercmdagent
                          /usr/share/triggercmdagent/triggercmdagent: symbol lookup error: /usr/share/triggercmdagent/triggercmdagent: undefined symbol: gtk_widget_get_scale_factor
                          [jhupcey@orw-mobile-vm ~]$
                          

                          What next?

                          J 1 Reply Last reply Reply Quote 0
                          • J
                            Joe @Joe
                            last edited by

                            Edited to add: presuming there are no more easy tweaks to be made here, I'm willing to do a complete re-install from scratch and potentially save us all some time. Please advise.


                            While I have the floor: FYI, some background on my objectives here:

                            • The baseline need is to launch a program tool from the command line with an Alexa voice command in my Linux VM
                            • Next, once the given tool(s) GUIs are open, I'd use voice commands to launch pre-made "do files" to execute specific flows in the tool(s)
                            • In a perfect world, I'd also be able to map Alexa voice commands to "macros of menu commands" similar to what you can do with WSH in MS Windows
                            RussR 1 Reply Last reply Reply Quote 0
                            • RussR
                              Russ @Joe
                              last edited by

                              @Joe, you might want to try a fresh VM or uninstall/reinstall because I'm not familiar with that gtk_widget_get_scale_factor error.

                              Another way to run the agent is this:

                              node /usr/share/triggercmdagent/resources/app/src/agent.js --console
                              

                              That path assumes Ubuntu. If that works, you might be able to salvage your install.

                              Russell VanderMey

                              1 Reply Last reply Reply Quote 0
                              • J
                                Joe
                                last edited by

                                Thanks, @Russ !

                                The VM is Red Hat Enterprise 7.1, but I tried the "node" command you cited above anyway.

                                The result:

                                • a new "Computer" did appear in https://www.triggercmd.com/user/computer/list, but no Triggers appeared.
                                • Interesting that Alexa still gave me a hearty "Ok" when I asked for "Hello World" and "Calculator", but nothing happened

                                At this point I think it's best to go ahead and do a full UNinstall, contemplate all the advice you've provided above, then do a fresh reinstall.

                                Any tips for a complete, scorched earth TriggerCMD UNinstall on this Red Hat Linux VM before I do a reinstall?


                                P.S. For anyone else following this thread, my TriggerCMD instances on my Raspberry Pi and MS Windows machine are doing fine. I think this Linux dust-up is simply due to my relative inexperience dealing with a Red Hat VM distro

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

                                  @Joe, it could be that the reason Alexa said "OK" was you're using the Smart Home skill and she still thinks you have some "devices" there. The way to fix that is to go here and click Remove All, then Discover. I've done my best to synchronize the commands with your Alexa devices, but there are still scenarios where they can get out of sync. This is one reason you should test in this order:

                                  1. Use the green play button in the GUI editor if you're using it.
                                  2. Use the green Trigger button on the website.
                                  3. Use Alexa

                                  You could try this procedure to re-install the agent, but you might need something more dramatic, like a fresh VM.

                                  Russell VanderMey

                                  1 Reply Last reply Reply Quote 0
                                  • J
                                    Joe
                                    last edited by

                                    Thanks again, @Russ for the support and the added tech tips!

                                    I'll do a reinstall and report back.

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      Joe
                                      last edited by

                                      Update: unfortunately, no luck on the re-install of the triggercmdagent-1.0.1.x86_64.rpm

                                      First, I'm not seeing the Linux VM "Computer" getting re-listed in https://www.triggercmd.com/user/computer/list

                                      When I run triggercmd agent as me after the re-install I get the now familiar error:

                                      [jhupcey@orw-mobile-vm ~]$ triggercmdagent
                                      /usr/share/triggercmdagent/triggercmdagent: symbol lookup error: /usr/share/triggercmdagent/triggercmdagent: undefined symbol: gtk_widget_get_scale_factor
                                      [jhupcey@orw-mobile-vm ~]$
                                      

                                      For the heck of it I also have logged into another window as root, and executing triggercmdagent in /root does nothing. For curiosities sake / playing a hunch, I cd'ed into .TRIGGERcmdData, and ran the triggercmdagent.service, and at least I get the following more promising error messages:

                                      [root@orw-mobile-vm ~]# 
                                      [root@orw-mobile-vm ~]# pwd
                                      /root
                                      [root@orw-mobile-vm ~]# cd .TRIGGERcmdData/
                                      [root@orw-mobile-vm .TRIGGERcmdData]# ls -la
                                      total 32
                                      drwxr-xr-x   2 root root 4096 May 23 15:06 .
                                      dr-xr-x---. 23 root root 4096 May 23 14:52 ..
                                      -rw-r--r--   1 root root  384 May 20 22:31 commands.json
                                      -rw-r--r--   1 root root  384 May 23 15:06 commands.json.backup
                                      -rw-r--r--   1 root root   24 May 17 19:07 computerid.cfg
                                      -rw-r--r--   1 root root  516 May 17 19:07 sendresult.sh
                                      -rw-r--r--   1 root root  148 May 17 19:07 token.tkn
                                      -rwxr-xr-x   1 root root  230 May 17 19:26 triggercmdagent.service
                                      [root@orw-mobile-vm .TRIGGERcmdData]# ./triggercmdagent.service 
                                      ./triggercmdagent.service: line 1: [Unit]: command not found
                                      ./triggercmdagent.service: line 2: Agent: command not found
                                      ./triggercmdagent.service: line 4: [Service]: command not found
                                      Running Linux daemon to run background tasks.
                                      Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
                                      Tokenfile: /root/.TRIGGERcmdData/token.tkn
                                      ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
                                      Logging in with saved token to run background tasks.
                                      Write backup completed.
                                      
                                      
                                        |>    Now connected to https://www.triggercmd.com.
                                      \___/   For help, see: http://bit.ly/2q0QDpf
                                              (using sails.io.js node SDK @v1.2.1)
                                               Connected at: Sat May 23 2020 15:19:16 GMT-0700 (PDT)
                                      
                                      
                                      
                                      Initiated command removals
                                      { message: 'Subscribed to 5ec1edf375b86f0019cd1a2c!' }
                                      { message: 'Subscribed to 5ec1edf375b86f0019cd1a2c!' }
                                      Initiated command adds
                                      Failed while trying add a trigger.
                                      

                                      Am I getting any closer, or am I just embarrassing myself at this point?

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

                                        @Joe, can you try this command? After googling that error I think it's basically saying it can't run the Chromium based GUI portion of the agent. This command runs the agent without the GUI:

                                        triggercmdagent --console
                                        

                                        Also I saw that it couldn't add a trigger. To fix that you could start fresh by deleting your .TRIGGERcmdData folder and the computer in your account.

                                        Russell VanderMey

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          Joe
                                          last edited by Joe

                                          Here is the result (run as me, not as root -- for root nothing happens):

                                          [jhupcey@orw-mobile-vm ~]$ triggercmdagent --console
                                          squirrelEvent --console
                                          /usr/share/triggercmdagent/triggercmdagent --console: symbol lookup error: /usr/share/triggercmdagent/triggercmdagent --console: undefined symbol: gtk_widget_get_scale_factor
                                          [jhupcey@orw-mobile-vm ~]$
                                          

                                          Possibly related: looking at the timestamps in /root/.TRIGGERcmdData (above) all the timestamps are from the initial install. My point being: whatever I run as me, does it get superceeded by this "stale" root stuff ? Hence, to do a pure UNinstall, should I do some sort of "rm -r" all this, stop some systemctl service, rm -r the <my_home>/.TRIGGERcmdData?

                                          1 Reply Last reply Reply Quote 0
                                          • J
                                            Joe
                                            last edited by

                                            Update: apologies -- I didn't see the second part of your prior comment.

                                            I will delete both the root and my .TRIGGERcmdData folders and start over.

                                            Stay tuned ...

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