Using the cli to receive sms messages, at a command prompt:
sudo hologram receive --sms
and when I send an sms from the Hologram Dashboard the message is displayed then a blank line is displayed.
If I send another sms, that message is displayed and a new blank line is displayed.
I would like to assign the message received to a bash variable.
I have figured out how to do this usign the python but would prefer to use bash.
An help would be appreciated.
I’ve figured out a work-around; re-direct the output of the script to a text file (msg.txt in this case)
sudo hologram receive --sms > msg.txt 2>&1
but since there is no timeout although an empty file msg.txt is created (even if there was a non empty file msg.txt) the re-directed output ONLY gets written to the file when the script closes.
sudo hologram receive --sms -t 60 > msg.txt 2>&1
causes the script to time out after 60 seconds and any sms receved - the message will be in msg.txt
I’ve discovered if sudo hologram receive --sms -t 60 > msg.txt 2>&1
is not currently running, and sms messages are sent, they are kept (presumably) on the Hologram cloud and get sent to the device when the script is next run. This and the fact two messages could be received within the 60 seconds the script is running, more than one message may be in msg.txt.
Haven’t done it yet, but it should be able to get the message(s) from msg.txt to a variable in another bash script.
Hope this helps someone & if someone has a better way to get a sms message to a bash variable please post it.
str=“this is a test”
str=$(sudo hologram receive --sms -t 60)
works like a charm.
Will need to parce $str to get only the message.