ancris00
Posts: 52
Joined: Sun Jan 19, 2020 8:56 pm
Location: Miranda de Ebro, Spain

Problem in coding

Sat Apr 11, 2020 9:54 pm

Hi all,
I have an script that send a photo through Telegram:

Code: Select all

#!/bin/bash
tgpath=/home/pi/tg
cd ${tgpath}
(sleep 3; echo "send_photo $1 $2"; echo "safe_quit") | ${tgpath}/bin/telegram-cli -k tg-server.pub -W
Then I run the following command:

Code: Select all

/home/pi/tg_photo.sh <firstname>_<lastname> /home/pi/photo.jpg
I want to just run the command /home/pi/tg_photo.sh

without writing: <firstname>_<lastname> /home/pi/photo.jpg

So I modified the script:

Code: Select all

#!/bin/bash
tgpath=/home/pi/tg
cd ${tgpath}
(sleep 3; echo "send_photo <firstname>_<lastname> /home/pi/photo.jpg"; echo "safe_quit") | ${tgpath}/bin/telegram-cli -k tg-server.pub -W
but I does not work

any help?
Thanks
:lol: :lol: Pi 4 Model B :lol: :lol:
Raspbian Buster with desktop 4.19

ejolson
Posts: 5373
Joined: Tue Mar 18, 2014 11:47 am

Re: Problem in coding

Sat Apr 11, 2020 10:09 pm

ancris00 wrote:
Sat Apr 11, 2020 9:54 pm
Hi all,
I have an script that send a photo through Telegram:

Code: Select all

#!/bin/bash
tgpath=/home/pi/tg
cd ${tgpath}
(sleep 3; echo "send_photo $1 $2"; echo "safe_quit") | ${tgpath}/bin/telegram-cli -k tg-server.pub -W
Then I run the following command:

Code: Select all

/home/pi/tg_photo.sh <firstname>_<lastname> /home/pi/photo.jpg
I want to just run the command /home/pi/tg_photo.sh

without writing: <firstname>_<lastname> /home/pi/photo.jpg

So I modified the script:

Code: Select all

#!/bin/bash
tgpath=/home/pi/tg
cd ${tgpath}
(sleep 3; echo "send_photo <firstname>_<lastname> /home/pi/photo.jpg"; echo "safe_quit") | ${tgpath}/bin/telegram-cli -k tg-server.pub -W
but I does not work

any help?
Thanks
What is the sleep 3 for?

User avatar
dickon
Posts: 1539
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Problem in coding

Sat Apr 11, 2020 10:12 pm

ejolson wrote:
Sat Apr 11, 2020 10:09 pm
What is the sleep 3 for?
I was wondering that. I'd expect something similar between or after the two echo commands, not before them.

ancris00
Posts: 52
Joined: Sun Jan 19, 2020 8:56 pm
Location: Miranda de Ebro, Spain

Re: Problem in coding

Sun Apr 12, 2020 12:21 pm

Hi,
I don't know for what is the sleep 3
but apart from that?
:lol: :lol: Pi 4 Model B :lol: :lol:
Raspbian Buster with desktop 4.19

Return to “Advanced users”