• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
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
6.8k
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.
  • R
    Russ @Antonio Francisco S.Santos
    last edited by Russ Feb 10, 2023, 7:20 PM Feb 10, 2023, 2:07 PM

    @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

    A 1 Reply Last reply Feb 15, 2023, 1:28 AM Reply Quote 0
    • A
      Antonio Francisco S.Santos @Antonio Francisco S.Santos
      last edited by Feb 15, 2023, 1:22 AM

      @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
      • A
        Antonio Francisco S.Santos @Russ
        last edited by Feb 15, 2023, 1:28 AM

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

        R 1 Reply Last reply Feb 15, 2023, 2:17 AM Reply Quote 0
        • R
          Russ @Antonio Francisco S.Santos
          last edited by Russ Feb 15, 2023, 2:18 AM Feb 15, 2023, 2:17 AM

          @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
          • A
            Antonio Francisco S.Santos
            last edited by Feb 16, 2023, 12:56 AM

            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
            • A
              Antonio Francisco S.Santos
              last edited by Feb 16, 2023, 1:01 AM

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

              R 1 Reply Last reply Feb 16, 2023, 1:48 AM Reply Quote 0
              • R
                Russ @Antonio Francisco S.Santos
                last edited by Feb 16, 2023, 1:48 AM

                @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
                • A
                  Antonio Francisco S.Santos
                  last edited by Feb 16, 2023, 7:59 PM

                  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
                  • A
                    Antonio Francisco S.Santos
                    last edited by Feb 16, 2023, 8:02 PM

                    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
                    • A
                      Antonio Francisco S.Santos
                      last edited by Feb 16, 2023, 10:57 PM

                      Log.jpg

                      R 1 Reply Last reply Feb 16, 2023, 11:00 PM Reply Quote 0
                      • R
                        Russ @Antonio Francisco S.Santos
                        last edited by Russ Feb 16, 2023, 11:01 PM Feb 16, 2023, 11:00 PM

                        @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
                        • A
                          Antonio Francisco S.Santos
                          last edited by Feb 16, 2023, 11:46 PM

                          @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

                          R 1 Reply Last reply Feb 17, 2023, 12:05 AM Reply Quote 0
                          • R
                            Russ @Antonio Francisco S.Santos
                            last edited by Feb 17, 2023, 12:05 AM

                            @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
                            • A
                              Antonio Francisco S.Santos
                              last edited by Feb 17, 2023, 12:53 AM

                              @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
                              • A
                                Antonio Francisco S.Santos
                                last edited by Feb 17, 2023, 12:56 AM

                                @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
                                • A
                                  Antonio Francisco S.Santos
                                  last edited by Feb 17, 2023, 1:01 AM

                                  @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.

                                  R 1 Reply Last reply Feb 17, 2023, 9:50 PM Reply Quote 0
                                  • R
                                    Russ @Antonio Francisco S.Santos
                                    last edited by Russ Feb 17, 2023, 9:51 PM Feb 17, 2023, 9:50 PM

                                    @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

                                    A 1 Reply Last reply Feb 22, 2023, 1:58 PM Reply Quote 0
                                    • A
                                      Antonio Francisco S.Santos @Russ
                                      last edited by Feb 22, 2023, 1:58 PM

                                      @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

                                      R 1 Reply Last reply Feb 23, 2023, 3:05 AM Reply Quote 0
                                      • R
                                        Russ @Antonio Francisco S.Santos
                                        last edited by Russ Feb 23, 2023, 3:08 AM Feb 23, 2023, 3:05 AM

                                        @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

                                        A 1 Reply Last reply Feb 23, 2023, 10:52 AM Reply Quote 0
                                        • A
                                          Antonio Francisco S.Santos @Russ
                                          last edited by Feb 23, 2023, 10:52 AM

                                          @Russ Bom dia, O Script KickBall.py tinha um erro na visualização do vídeo e esse script não da nenhum retorno ao clicar no gatilho.
                                          Me mostre como faço o script para ter um retorno de log?. Acho que o arquivo Follow deve ter algum comando na sua composição que impede que o Trigger funcione.

                                          R 1 Reply Last reply Feb 23, 2023, 1:44 PM Reply Quote 0
                                          36 out of 80
                                          • First post
                                            36/80
                                            Last post