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

    Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo

    Raspberry Pi
    2
    80
    5.3k
    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.
    • Antonio Francisco S.SantosA
      Antonio Francisco S.Santos
      last edited by

      Olá, Alguns comandos funcionam, mas alguns não faz nada quando clico no botão verde e como faço pra ver o histórico de erro?

      RussR Antonio Francisco S.SantosA 2 Replies Last reply Reply Quote 0
      • RussR
        Russ @Antonio Francisco S.Santos
        last edited by Russ

        @Antonio-Francisco-S-Santos, on Linux, you can send the output of a command to a log file by directing the output to a file.

        If your command is:

        ~/script.sh
        

        Change your command to this:

        ~/script.sh >> /tmp/script.log 2>&1
        

        Then view the log file like this:

        cat /tmp/script.log
        

        Russell VanderMey

        Antonio Francisco S.SantosA 1 Reply Last reply Reply Quote 0
        • Antonio Francisco S.SantosA
          Antonio Francisco S.Santos @Antonio Francisco S.Santos
          last edited by

          @Antonio-Francisco-S-Santos Boa Noite Amigo, os Scripts estão funcionando perfeitamente, mas tem um script que não funciona de maneira alguma já fiz do mesmo jeito que montei os outros mas quando clico nada faz. O que pode ser?

          1 Reply Last reply Reply Quote 0
          • Antonio Francisco S.SantosA
            Antonio Francisco S.Santos @Russ
            last edited by

            @Russ #!/bin/bash
            touch .Xauthority
            xauth merge ~pi/.Xauthority
            export DISPLAY=:0.0
            /home/pi/TonyPi/Functions/Follow.py

            RussR 1 Reply Last reply Reply Quote 0
            • RussR
              Russ @Antonio Francisco S.Santos
              last edited by Russ

              @Antonio-Francisco-S-Santos said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:

              touch .Xauthority
              xauth merge ~pi/.Xauthority
              export DISPLAY=:0.0
              /home/pi/TonyPi/Functions/Follow.py

              I think you should change that first touch line to this:

              touch ~/.Xauthority
              

              That way the .Xauthority file will be created in your user's home folder instead of whatever happens to be the working directory.

              Did you update the command to capture the output of that script? It would help in troubleshooting to see the output in the log file.

              Your command would be something like this to produce the /tmp/follow.log file:

              {"trigger":"Follow","command":"/home/pi/TonyPi/Functions/follow.sh >> /tmp/follow.log 2>&1","ground":"foreground","voice":"follow","allowParams": "false"},
              

              I used ground = foreground because I'm assuming you're running foreground triggercmd agent by running it in a terminal window with triggercmdagent --console. Please confirm. If you're running it in the background agent (as root), change ground to background.

              Russell VanderMey

              1 Reply Last reply Reply Quote 0
              • Antonio Francisco S.SantosA
                Antonio Francisco S.Santos
                last edited by

                Tentei nessa forma que você me mandou mas ainda não funcionou, Criei os dois Script um Python3 (Python3) e outro bash (Me-Siga)
                Imagem3.jpg Imagem2.jpg Imagem1.jpg

                1 Reply Last reply Reply Quote 0
                • Antonio Francisco S.SantosA
                  Antonio Francisco S.Santos
                  last edited by

                  {"trigger":"Me-Siga","command":"/home/pi/TonyPi/Functions/Me-Siga.sh >> /tmp/Me-Siga.log 2>&1","ground":"background","voice":"Me-Siga","allowParams": "false"},

                  RussR 1 Reply Last reply Reply Quote 0
                  • RussR
                    Russ @Antonio Francisco S.Santos
                    last edited by

                    @Antonio-Francisco-S-Santos, can you show me the output of these commands?

                    Show the contents of your log file, if it exists:

                    cat /tmp/Me-Siga.log
                    

                    Show the /home/pi/TonyPi/Functions/Me-Siga.sh file's permissions:

                    ls -al /home/pi/TonyPi/Functions/Me-Siga.sh
                    

                    I'd like to see if it's executable. If it's not, you can make it executable with this command:

                    chmod +x /home/pi/TonyPi/Functions/Me-Siga.sh
                    

                    Show whether the background agent is started:

                    systemctl status triggercmdagent
                    

                    Did you run this command already?

                    xhost +
                    

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • Antonio Francisco S.SantosA
                      Antonio Francisco S.Santos
                      last edited by

                      Eu já tentei criar o arquivo de log mas não consigo e ao executar esse Script (Me-Siga.sh) aparece a mensagem que não encontrou o arquivo ou arquivo inexistente:
                      Me-Siga.sh2.jpg Me-siga.sh.jpg Follow.py (1).jpg

                      1 Reply Last reply Reply Quote 0
                      • Antonio Francisco S.SantosA
                        Antonio Francisco S.Santos
                        last edited by

                        Todos os outros comandos dessa pasta ( Functions ) funciona ´só esse Follow que quando clico no botão verde Trigger ele não responde

                        1 Reply Last reply Reply Quote 0
                        • Antonio Francisco S.SantosA
                          Antonio Francisco S.Santos
                          last edited by

                          Log.jpg

                          RussR 1 Reply Last reply Reply Quote 0
                          • RussR
                            Russ @Antonio Francisco S.Santos
                            last edited by Russ

                            @Antonio-Francisco-S-Santos, you still haven't told me if you're getting something in the /tmp/Me-Siga.log file or not.

                            Before we troubleshoot the script I need to know whether the command is running. If you get something in /tmp/Me-Siga.log then we'll know it is running.

                            Please run this command and show me the result:

                            cat /tmp/Me-Siga.log
                            

                            Russell VanderMey

                            1 Reply Last reply Reply Quote 0
                            • Antonio Francisco S.SantosA
                              Antonio Francisco S.Santos
                              last edited by

                              @Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:

                              cat /tmp/Me-Siga.log

                              Quando executo esse comando aparece essa resposta:
                              cat: /tmp/Me-Siga.log: Arquivo ou diret▒rio inexistente

                              Executei o comando no terminal shell

                              RussR 1 Reply Last reply Reply Quote 0
                              • RussR
                                Russ @Antonio Francisco S.Santos
                                last edited by

                                @Antonio-Francisco-S-Santos, interresting. It doesn't seem to be running because you aren't getting anything in the log file.

                                Will you please try running the script as root manually? I'm curious if that works.

                                sudo su -
                                /home/pi/TonyPi/Functions/Me-Siga.sh
                                

                                Also, please try adding this line to your Me-Siga.sh script:

                                echo "Me-Siga.sh script ran." >> /tmp/Me-Siga.log
                                

                                Also, please confirm:

                                You ran xhost + as pi.
                                In your /root/.TRIGGERcmdData/commands.json file, ground = background.

                                Russell VanderMey

                                1 Reply Last reply Reply Quote 0
                                • Antonio Francisco S.SantosA
                                  Antonio Francisco S.Santos
                                  last edited by

                                  @Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:

                                  /home/pi/TonyPi/Functions/Me-Siga.sh

                                  já executei esse comando como root mas não funcionou: /home/pi/TonyPi/Functions/Me-Siga.sh
                                  também já tentei como comando echo mas não funcionou o Script não responde

                                  1 Reply Last reply Reply Quote 0
                                  • Antonio Francisco S.SantosA
                                    Antonio Francisco S.Santos
                                    last edited by

                                    @Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:

                                    /root/.TRIGGERcmdData/commands.json, ground = background.

                                    não da permissão quando executo esse comando:
                                    /root/.TRIGGERcmdData/commands.json, ground = background.

                                    1 Reply Last reply Reply Quote 0
                                    • Antonio Francisco S.SantosA
                                      Antonio Francisco S.Santos
                                      last edited by

                                      @Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:

                                      cat /tmp/Me-Siga.log

                                      Também quando executo esse comando: cat /tmp/Me-Siga.log recebo isso: Me-Siga.sh script ran.

                                      RussR 1 Reply Last reply Reply Quote 0
                                      • RussR
                                        Russ @Antonio Francisco S.Santos
                                        last edited by Russ

                                        @Antonio-Francisco-S-Santos, good, so this line that you added to your script

                                        echo "Me-Siga.sh script ran." >> /tmp/Me-Siga.log
                                        

                                        Must have writen this to your /tmp/Me-Siga.log file:

                                        Me-Siga.sh script ran.
                                        

                                        Did it add that line when your ran the script manually as root? Or when you ran it via TRIGGERcmd? If you don't know, can you test that? Just cat the log before and after you run it.

                                        I just want to establish whether TRIGGERcmd is running your script or not before troubleshooting the content of your script.

                                        Russell VanderMey

                                        Antonio Francisco S.SantosA 1 Reply Last reply Reply Quote 0
                                        • Antonio Francisco S.SantosA
                                          Antonio Francisco S.Santos @Russ
                                          last edited by

                                          @Russ Bom dia Professor, Ainda não conseguir resolver o Script com esse arquivo0 (Follow.py) Se os outros funcionam perfeitamente. Quando pego o Script que criei (Me-siga.sh) e modifico para outro arquivo no Trigger deixando assim: (/home/pi/TonyPi/Functions/Buzeer.py) ele funciona mas quando deixo assim: (/home/pi/TonyPi/Functions/Follow.py) não responde.
                                          esse é o Arquivo Follow.py:
                                          Follow.jpg

                                          RussR 1 Reply Last reply Reply Quote 0
                                          • RussR
                                            Russ @Antonio Francisco S.Santos
                                            last edited by Russ

                                            @Antonio-Francisco-S-Santos, I don't know why that particular python script won't work. I would have to see the output to troubleshoot it.

                                            For some reason sending the output to a log didn't work, but if you run it manually, do you get any output you could send me?

                                            Or is it the same error you got with the KickBall.py script?

                                            Can't initialize GTK backend in function 'cvInitSystem'
                                            

                                            Russell VanderMey

                                            Antonio Francisco S.SantosA 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post