vysheng / tg

telegram-cli
GNU General Public License v2.0
6.49k stars 1.54k forks source link

Hangup when calling from FHEM context #531

Open dma7 opened 9 years ago

dma7 commented 9 years ago

I'm using the most recent version of telegram-cli from FHEM on Raspberry Pi. I've registered successfully and when I try to send a message interactively, it works perfectly.

I have created a simple script called sendmsg

!/bin/bash

/opt/fhem/tg/bin/telegram-cli -c /opt/fhem/.telegram-cli/config -vvvv -WR -e "msg $1 $2; safe_quit"

It is execuded from FHEM via the following method sub SendNotificationTelegram($) { my ($str) = @_; system("/opt/fhem/tg/bin/sendmsg user#ABC \"$str\" >/tmp/tg.log"); }

The script is also working when it is called from pi's context.

When I call it from FHEM it seems to hang up. Looking into tg.log shows the following output:

Telegram-cli version 1.3.1, Copyright (C) 2013-2015 Vitaly Valtman Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'. This is free software, and you are welcome to redistribute it under certain conditions; typeshow_license' for details. Telegram-cli uses libtgl version 2.0.1 * public key '/etc/telegram-cli/server.pub' loaded successfully * Couldn't open public key file: tg-server.pub * Can not load key tg-server.pub * DC1 '' update: 149.154.175.50:443 * DC2 '' update: 149.154.167.51:443 * DC3 '' update: 149.154.175.100:443 * DC4 '' update: 149.154.167.91:443 * DC5 '' update: 149.154.171.5:443 * outbound rpc connection from dc #4 becomed ready * outbound rpc connection from dc #2 becomed ready * outbound rpc connection from dc #1 becomed ready * outbound rpc connection from dc #3 becomed ready * outbound rpc connection from dc #5 becomed ready * adjusting CLOCK_MONOTONIC delta to 0.700920 * adjusting CLOCK_MONOTONIC delta to -1.686433 * adjusting CLOCK_MONOTONIC delta to -2.688478 * adjusting CLOCK_MONOTONIC delta to -0.687582 * adjusting CLOCK_MONOTONIC delta to -2.758099 phone number: SIGTERM/SIGINT received halt

Do you have any idea how to get it working?

dma7 commented 9 years ago

In the meantime, I was able to fix the issue myself.

In FHEM, I had to change the call of my script to the below

system("sudo -u fhem /opt/fhem/tg/bin/sendmsg user#ABC \"$str\" >/tmp/tg.log"); }