3

I don't know how to explain myself but I need to send scheduled messages via telegram so I downloaded the telegram client to send messages via terminal. I wrote a bash script that opens the client, everything here is going according to plan then it opens the telegram command line and my script doesn't run accordingly. How can I make work?

this is the telegram command line

This is the script, nothing difficult:

#!/bin/bash
cd /home/ospite/tg
bin/telegram-cli -k tg-server.pub //opening telegram client
sleep 30
chat_with_peer Antonio //it doesn't work because it's not the debian shell anymore
done
  • 1
    For very simple cases, you may be able to pipe a command sequence via standard input, either using echo, printf (better), or a here-document using cat. For more complicated interactions, you will probably need to use something like expect – steeldriver Nov 22 '16 at 23:09
  • Welcome to askubuntu!Please open a terminal and issue the command lsb_release -a and edit the output into your post. Thank you for helping us help you! – Elder Geek Nov 22 '16 at 23:31
3

To write a script to send messages over telegram-cli, you need to do the following:

  1. Move to the directory where telegram-cli is:

  2. Open telegram-cli with your key

  3. Load your contact list with -W

  4. Send the message to anyone on your contact list previously loaded

To achieve that:

cd /path/to/tg && bin/telegram-cli -W server.pub -e "msg contact message"

or

cd /path/to/tg && (sleep 1; echo "contact_list"; sleep 1; echo "msg contact message") | bin/telegram-cli -W -k server.pub

More info here: https://github.com/vysheng/tg

  • you sir, saved my day – Juggernaut May 17 '17 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.