Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo
-
@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. -
@Antonio-Francisco-S-Santos, to get the output, run this from a terminal window:
python3 /home/pi/TonyPi/Functions/Follow.py
Or to capture the output to a log, run this command instead:
python3 /home/pi/TonyPi/Functions/Follow.py > /tmp/follow.log 2>&1
-
@Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:
python3 /home/pi/TonyPi/Functions/Follow.py
Entçao, quando executo esse Script (python3 /home/pi/TonyPi/Functions/Follow.py )
ele funciona, e quando executo esse ( python3 /home/pi/TonyPi/Functions/Follow.py > /tmp/follow.log 2>&1 ) recebo esse Arquivo TMP:
-
@Antonio-Francisco-S-Santos Também quando executo o Script pelo Trigger ( #!/bin/bash
export DISPLAY=:0.0
/usr/bin/python3 src/main.py --debug
python3 /home/pi/TonyPi/Functions/Follow.py > /tmp/follow.log 2>&1 ) no arquivo Bash recebo esse arquivo TMP:
-
@Antonio-Francisco-S-Santos No caso o erro que esta acontecendo é esse aqui:
( Traceback (most recent call last):
File "/home/pi/TonyPi/Functions/Follow.py", line 10, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas' ) -
@Antonio-Francisco-S-Santos, you need to install the pandas module with one of these commands. I'd try the first one first.
sudo pip3 install pandas
sudo apt-get install python3-pandas
-
@Russ Olá Professor, você é fera mesmo viu, deu certo funcionou o Script ( Follow ) Instalei o Pandas e deu certo muito obrigado você é o mestre mesmo.
-
Awesome @Antonio-Francisco-S-Santos. I'm glad it's working now.
-
@Russ Olá Professor, Como faço um script para fechar os script quando executado, Ex:
{"trigger":"Sonar_barrier.py","command":"/home/pi/TonyPi/Extend/Caminhar.sh","ground":"background","voice":"Caminhar","allowParams": "false"}para fechar esse comando ( Sonar_barrier.py) quando estiver rodando?
-
@Antonio-Francisco-S-Santos, if you don't mind killing all instances of python3, you could use this command:
killall python3
You could make that your "Off Command" so when you turn the virtual device off, it runs the killall command.
{"trigger":"Sonar_barrier.py","command":"/home/pi/TonyPi/Extend/Caminhar.sh","offCommand":"killall python3","ground":"background","voice":"Caminhar","allowParams": "false"}
-
@Russ Muito obrigado meu Amigo, ele funciona mas desliga o Robô após fechar o Script. kkkkk
Na realidade estou querendo fechar só o Script que estar rodando no momento. No caso um outro Script que fecha os outros quando estiver rodando. -
Boa Tarde Professor, Até hoje não conseguir fechar um Script em execução pelo TrigeerCmd, mesmo usando o camando killall não fecha o script sem desligar o
sistema do raspberry pi -
@Antonio-Francisco-S-Santos, while the python script is running, please run this, then paste the result when you reply:
ps -ef
I'm hoping that information will show me a way you can kill your python script.
-
@Antonio-Francisco-S-Santos UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:44 ? 00:00:04 /sbin/init splash
root 2 0 0 16:44 ? 00:00:00 [kthreadd]
root 3 2 0 16:44 ? 00:00:00 [rcu_gp]
root 4 2 0 16:44 ? 00:00:00 [rcu_par_gp]
root 8 2 0 16:44 ? 00:00:00 [mm_percpu_wq]
root 9 2 0 16:44 ? 00:00:00 [rcu_tasks_rude_]
root 10 2 0 16:44 ? 00:00:00 [rcu_tasks_trace]
root 11 2 0 16:44 ? 00:00:00 [ksoftirqd/0]
root 12 2 0 16:44 ? 00:00:07 [rcu_sched]
root 13 2 0 16:44 ? 00:00:00 [migration/0]
root 14 2 0 16:44 ? 00:00:00 [cpuhp/0]
root 15 2 0 16:44 ? 00:00:00 [cpuhp/1]
root 16 2 0 16:44 ? 00:00:00 [migration/1]
root 17 2 0 16:44 ? 00:00:00 [ksoftirqd/1]
root 20 2 0 16:44 ? 00:00:00 [cpuhp/2]
root 21 2 0 16:44 ? 00:00:00 [migration/2]
root 22 2 0 16:44 ? 00:00:00 [ksoftirqd/2]
root 25 2 0 16:44 ? 00:00:00 [cpuhp/3]
root 26 2 0 16:44 ? 00:00:00 [migration/3]
root 27 2 0 16:44 ? 00:00:00 [ksoftirqd/3]
root 29 2 0 16:44 ? 00:00:00 [kworker/3:0H-kblockd]
root 30 2 0 16:44 ? 00:00:00 [kdevtmpfs]
root 31 2 0 16:44 ? 00:00:00 [netns]
root 33 2 0 16:44 ? 00:00:00 [kworker/1:1-events]
root 34 2 0 16:44 ? 00:00:00 [kauditd]
root 36 2 0 16:44 ? 00:00:00 [khungtaskd]
root 37 2 0 16:44 ? 00:00:00 [oom_reaper]
root 38 2 0 16:44 ? 00:00:00 [writeback]
root 39 2 0 16:44 ? 00:00:00 [kcompactd0]
root 59 2 0 16:44 ? 00:00:00 [kblockd]
root 60 2 0 16:44 ? 00:00:00 [blkcg_punt_bio]
root 61 2 0 16:44 ? 00:00:00 [watchdogd]
root 62 2 0 16:44 ? 00:00:00 [kworker/0:1H-mmc_complete]
root 63 2 0 16:44 ? 00:00:00 [rpciod]
root 65 2 0 16:44 ? 00:00:00 [xprtiod]
root 66 2 0 16:44 ? 00:00:00 [kswapd0]
root 67 2 0 16:44 ? 00:00:00 [nfsiod]
root 68 2 0 16:44 ? 00:00:00 [kthrotld]
root 71 2 0 16:44 ? 00:00:00 [iscsi_eh]
root 72 2 0 16:44 ? 00:00:00 [iscsi_destroy]
root 73 2 0 16:44 ? 00:00:00 [nvme-wq]
root 74 2 0 16:44 ? 00:00:00 [nvme-reset-wq]
root 75 2 0 16:44 ? 00:00:00 [nvme-delete-wq]
root 78 2 0 16:44 ? 00:00:00 [DWC Notificatio]
root 79 2 0 16:44 ? 00:00:00 [uas]
root 80 2 0 16:44 ? 00:00:07 [vchiq-slot/0]
root 81 2 0 16:44 ? 00:00:00 [vchiq-recy/0]
root 82 2 0 16:44 ? 00:00:00 [vchiq-sync/0]
root 83 2 0 16:44 ? 00:00:00 [zswap-shrink]
root 86 2 0 16:44 ? 00:00:01 [kworker/0:5-mm_percpu_wq]
root 87 2 0 16:44 ? 00:00:00 [sdhci]
root 88 2 0 16:44 ? 00:00:00 [irq/49-mmc0]
root 90 2 0 16:44 ? 00:00:00 [mmc_complete]
root 91 2 0 16:44 ? 00:00:00 [kworker/1:1H-kblockd]
root 92 2 0 16:44 ? 00:00:00 [kworker/1:2H-kblockd]
root 93 2 0 16:44 ? 00:00:00 [jbd2/mmcblk0p2-]
root 94 2 0 16:44 ? 00:00:00 [ext4-rsv-conver]
root 97 2 0 16:44 ? 00:00:00 [ipv6_addrconf]
root 98 2 0 16:44 ? 00:00:00 [kworker/3:2-mm_percpu_wq]
root 113 2 0 16:44 ? 00:00:00 [kworker/3:2H-kblockd]
root 115 2 0 16:44 ? 00:00:00 [kworker/2:2H-kblockd]
root 121 1 0 16:44 ? 00:00:01 /lib/systemd/systemd-journald
root 160 1 0 16:44 ? 00:00:00 /lib/systemd/systemd-udevd
root 204 2 0 16:44 ? 00:00:00 [vchiq-keep/0]
root 207 2 0 16:44 ? 00:00:00 [SMIO]
root 221 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 223 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 226 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 270 2 0 16:44 ? 00:00:00 [cfg80211]
root 273 2 0 16:44 ? 00:00:00 [brcmf_wq/mmc1:0]
root 275 2 0 16:44 ? 00:00:00 [brcmf_wdog/mmc1]
root 283 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 284 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 285 2 0 16:44 ? 00:00:00 [mmal-vchiq]
root 286 2 0 16:44 ? 00:00:00 [mmal-vchiq]
systemd+ 335 1 0 16:44 ? 00:00:00 /lib/systemd/systemd-timesyncd
root 338 1 0 16:44 ? 00:00:01 /usr/sbin/haveged --Foreground --verbose=1 -w 1024
root 376 1 0 16:44 ? 00:00:00 /usr/sbin/rsyslogd -n -iNONE
root 377 1 0 16:44 ? 00:00:04 node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData
root 378 1 0 16:44 ? 00:00:00 /usr/sbin/cupsd -l
root 379 1 0 16:44 ? 00:00:00 /usr/sbin/alsactl -E HOME=/run/alsa -s -n 19 -c rdaemon
avahi 381 1 0 16:44 ? 00:00:00 avahi-daemon: running [TonyPiPro.local]
root 382 1 0 16:44 ? 00:00:00 /usr/sbin/ModemManager --filter-policy=strict
root 383 1 0 16:44 ? 00:00:04 /usr/bin/python3 /home/pi/hiwonder-toolbox/hw_button_scan.py
root 386 1 0 16:44 ? 00:00:17 /usr/bin/python3 /home/pi/hiwonder-toolbox/hw_wifi.py
avahi 390 381 0 16:44 ? 00:00:00 avahi-daemon: chroot helper
message+ 391 1 0 16:44 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 396 1 0 16:44 ? 00:00:00 /usr/sbin/rngd -r /dev/hwrng
root 401 1 0 16:44 ? 00:00:00 /usr/lib/udisks2/udisksd
root 402 1 0 16:44 ? 00:00:00 /usr/sbin/cron -f
root 407 1 0 16:44 ? 00:00:00 /usr/bin/python3 /home/pi/hiwonder-toolbox/hw_remote.py
root 408 1 3 16:44 ? 00:02:20 /usr/bin/python3 /home/pi/TonyPi/TonyPi.py
root 410 1 6 16:44 ? 00:04:06 /usr/bin/pigpiod
nobody 416 1 0 16:44 ? 00:00:00 /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/e
root 417 1 0 16:44 ? 00:00:00 /lib/systemd/systemd-logind
root 430 1 0 16:44 ? 00:00:00 /usr/bin/python3 /home/pi/hiwonder-toolbox/hw_find.py -t TONYPIPRO
root 495 1 0 16:44 ? 00:00:00 /usr/sbin/cups-browsed
root 505 1 0 16:44 ? 00:00:00 /usr/bin/vncserver-x11-serviced -fg
root 516 505 0 16:44 ? 00:00:14 /usr/bin/vncserver-x11-core -service
root 526 1 0 16:44 ? 00:00:00 /usr/sbin/sshd -D
root 527 1 0 16:44 ? 00:00:00 /usr/lib/policykit-1/polkitd --no-debug
root 540 1 0 16:44 ? 00:00:00 /usr/sbin/lightdm
dnsmasq 549 1 0 16:44 ? 00:00:00 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg
root 629 540 2 16:44 tty7 00:01:17 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
root 634 1 0 16:44 tty1 00:00:00 /bin/login -f
root 643 1 0 16:44 ? 00:00:00 haveged
root 659 1 0 16:44 ? 00:00:06 /usr/bin/vncagent service 15
root 672 1 0 16:44 ? 00:00:00 /sbin/dhcpcd -q -b
root 691 1 0 16:44 ? 00:00:00 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext
root 711 540 0 16:44 ? 00:00:00 lightdm --session-child 14 17
pi 716 1 0 16:44 ? 00:00:00 /lib/systemd/systemd --user
pi 717 716 0 16:44 ? 00:00:00 (sd-pam)
pi 766 711 0 16:44 ? 00:00:00 /usr/bin/lxsession -s LXDE-pi -e LXDE
pi 774 716 0 16:44 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
pi 833 766 0 16:44 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/im-launch x-session-manager
pi 864 1 0 16:44 ? 00:00:00 /usr/bin/fcitx -d
pi 874 1 0 16:44 ? 00:00:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --config-file /usr/share/fcitx/dbus/daemon.conf
pi 878 1 0 16:44 ? 00:00:00 /usr/bin/fcitx-dbus-watcher unix:path=/tmp/dbus-Wd5SygDeF8,guid=3bff97bd434c9201ce685dc464710c18 874
pi 881 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfsd
pi 886 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
pi 895 766 0 16:44 ? 00:00:00 openbox --config-file /home/pi/.config/openbox/lxde-pi-rc.xml
pi 898 766 0 16:44 ? 00:00:00 lxpolkit
pi 904 766 0 16:44 ? 00:00:27 lxpanel --profile LXDE-pi
pi 905 766 0 16:44 ? 00:00:01 pcmanfm --desktop --profile LXDE-pi
pi 911 1 0 16:44 ? 00:00:00 /usr/bin/ssh-agent -s
pi 918 1 0 16:44 ? 00:00:00 /usr/bin/python3 /usr/share/system-config-printer/applet.py
pi 929 1 0 16:44 ? 00:00:00 /usr/lib/geoclue-2.0/demos/agent
pi 947 716 0 16:44 ? 00:00:00 /usr/bin/pulseaudio --daemonize=no
pi 952 1 0 16:44 ? 00:00:00 /usr/bin/vncserverui service 16
rtkit 969 1 0 16:44 ? 00:00:00 /usr/lib/rtkit/rtkit-daemon
pi 973 952 0 16:44 ? 00:00:00 /usr/bin/vncserverui -statusicon 5
pi 974 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
pi 986 634 0 16:44 tty1 00:00:00 -bash
pi 990 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi 1006 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
root 1009 1 0 16:44 ? 00:00:00 /usr/bin/hciattach /dev/serial1 bcm43xx 460800 noflow -
root 1010 2 0 16:44 ? 00:00:00 [kworker/u9:1-hci0]
root 1012 2 0 16:44 ? 00:00:00 [kworker/u9:2-hci0]
root 1013 1 0 16:44 ? 00:00:00 /usr/bin/python3 /home/pi/TonyPi/Extend/multi_control_server.py
root 1015 1 0 16:44 ? 00:00:15 /usr/bin/python3 /home/pi/TonyPi/Extend/multi_control_client.py
root 1017 1 1 16:44 ? 00:00:47 /usr/bin/python3 /home/pi/TonyPi/Joystick.py
pi 1028 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
root 1034 1 0 16:44 ? 00:00:00 /usr/lib/bluetooth/bluetoothd
pi 1040 1 0 16:44 ? 00:00:00 /usr/lib/menu-cache/menu-cached /run/user/1000/menu-cached-:0
pi 1044 716 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
root 1049 1 0 16:44 ? 00:00:00 /usr/bin/bluealsa
root 1056 2 0 16:44 ? 00:00:00 [krfcommd]
pi 1065 881 0 16:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.5 /org/gtk/gvfs/exec_spaw/0
lp 1258 378 0 16:44 ? 00:00:00 /usr/lib/cups/notifier/dbus dbus://
colord 1259 1 0 16:44 ? 00:00:00 /usr/lib/colord/colord
root 4879 2 0 17:14 ? 00:00:04 [kworker/u8:0-events_unbound]
root 5969 2 0 17:23 ? 00:00:00 [kworker/3:1]
root 6382 2 0 17:27 ? 00:00:04 [kworker/u8:1-events_unbound]
root 6900 2 0 17:31 ? 00:00:00 [kworker/2:1-events]
pi 6995 904 0 17:32 ? 00:00:00 lxterminal
pi 7004 6995 0 17:32 pts/0 00:00:00 bash
root 7082 2 0 17:32 ? 00:00:02 [kworker/u8:2-events_unbound]
root 7140 526 0 17:33 ? 00:00:00 sshd: pi [priv]
pi 7158 7140 0 17:33 ? 00:00:00 sshd: pi@pts/1
pi 7159 7158 0 17:33 pts/1 00:00:00 -bash
root 7380 2 0 17:35 ? 00:00:00 [kworker/0:2H]
root 7423 2 0 17:35 ? 00:00:00 [kworker/1:0]
root 7430 377 0 17:35 ? 00:00:00 /bin/sh -c /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 7431 7430 0 17:35 ? 00:00:00 /bin/bash /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 7434 7431 99 17:35 ? 00:18:18 /usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py
root 7456 1 0 17:35 ? 00:00:00 dbus-launch --autolaunch cb12512d764b467aa157bee72a6681fe --binary-syntax --close-stderr
root 7457 1 0 17:35 ? 00:00:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
root 7470 2 0 17:35 ? 00:00:00 [kworker/2:1H]
root 7474 2 0 17:35 ? 00:00:01 [kworker/0:2-events]
root 7583 2 0 17:36 ? 00:00:00 [kworker/2:0-mm_percpu_wq]
root 7767 377 0 17:37 ? 00:00:00 /bin/sh -c /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 7768 7767 0 17:37 ? 00:00:00 /bin/bash /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 7771 7768 1 17:37 ? 00:00:05 /usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py
root 7937 2 0 17:39 ? 00:00:00 [kworker/1:0H]
root 8114 2 0 17:40 ? 00:00:00 [kworker/0:0-events]
root 8115 377 0 17:40 ? 00:00:00 /bin/sh -c /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 8116 8115 0 17:40 ? 00:00:00 /bin/bash /home/pi/TonyPi/Extend/Pegar_Objeto.sh
root 8119 8116 1 17:40 ? 00:00:03 /usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py
root 8257 2 0 17:41 ? 00:00:00 [kworker/2:2-mm_percpu_wq]
root 8306 2 0 17:42 ? 00:00:00 [kworker/u8:3-events_unbound]
root 8343 377 0 17:42 ? 00:00:00 /bin/sh -c /home/pi/TonyPi/Extend/ApriltagTrack.py
root 8344 8343 2 17:42 ? 00:00:02 /usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py
pi 8539 7159 0 17:43 pts/1 00:00:00 ps -ef
pi@TonyPiPro:~ $ -
{"trigger":"Pegar_Objeto.sh","command":"/home/pi/TonyPi/Extend/Pegar_Objeto.sh","ground":"background","voice":"Pegar Objeto","allowParams": "false"},
-
{"trigger":"ApriltagTrack.py","command":"/home/pi/TonyPi/Extend/Pegar_Objeto.sh","offCommand":"killall python3","ground":"background","voice":"Pegar Objeto","allo$
-
@Antonio-Francisco-S-Santos, please try this as your offCommand after you confirm it works manually.
kill -9 $(pgrep -f "/usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py")
-
Executando direto do terminal aparece:
pi@TonyPiPro:~ $ kill -9 $(pgrep -f "/usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py")
-bash: kill: (1683) - Opera▒▒o n▒o permitida
pi@TonyPiPro:~ $ -
@Antonio-Francisco-S-Santos, it's saying you don't have access, so you'll need to prefix the command with sudo, like this:
sudo kill -9 $(pgrep -f "/usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py")
I see you're running the TRIGGERcmd background agent, which runs as root, so you don't need the sudo prefix when you add it to your commands.json.
You'll need to escape the command's quotes too, like this:
"offCommand": "kill -9 $(pgrep -f \"/usr/bin/python3 /home/pi/TonyPi/Extend/ApriltagTrack.py\")"
-
@Russ said in Tentando Executar um Script python no terminal LX com o TriggerCMD mas não estou conseguindo:
Quando tento montar o comando ele só salvar dessa maneira:
{"trigger":"Sonar_barrier.py","command":"/home/pi/TonyPi/Extend/Caminhar.sh","offCommand":"kill -9 $(pgrep -f","ground":"background","voice":"Caminhar","allowParams": "false"}