0

In the Termux app on Android I get a text file with all the SMSs like this:

termux-sms-list >sms.txt

And I need to send its content over xmpp automatically by script. The available command is xmppc, but it doesn't seem to support file uploads. I tried these ways and it didn't work:

xmppc -j [email protected] -p "UserPassword" -m message chat [email protected] $(cat sms.txt)

cat sms.txt | xmppc -j [email protected] -p "UserPassword" -m message chat [email protected] -

Any idea?

1 Answers1

0

I myself ended up finding a solution that works like a charm!

Obviously you must change the JID's and password.

while true ; do
# Get SMS's with a little treatment
    termux-sms-list | sed -u "/\"_id\":/d;/\"threadid\":/d;/\"read\":/d;/\"type\":/d;s/\"/'/g" >messages.txt
# Automatically creates a second script to send the messages embedded in the xmppc command
    echo '#!/bin/bash' >txt2xmpp.sh
    echo 'xmppc -j [email protected] -p "UserPassword" -m message chat [email protected] \' >>txt2xmpp.sh
# xmppc requires the message to be enclosed in double quotes
    echo "aaaaa$(cat messages.txt)aaaaa" | sed -u 's/aaaaa/\"/g' >>txt2xmpp.sh
# Run the second script
    bash txt2xmpp.sh
# Will repeat after 5 minutes
    sleep 5m
done

In the receiver's xmpp client the messages will be displayed in the following format:

[
  {
    'number': '+77777',
    'received': '2022-07-28 07:55:27',
    'body': 'SERVICE: check if you have an offer and get your accounts in order. Enjoy installments of 14x or more. trade: http://domain.tld/e',
  },
  {
    'number': '+88888',
    'received': '2022-07-28 07:55:28',
    'body': 'Bank: YourName, we want your opinion on your INTERNATIONAL card visit domain.tld/abcdef for a quick search. Cancel SMS:Send STOP',
  },
  {
    'number': '+99999',
    'received': '2022-07-28 07:55:29',
    'body': 'Your verification code is: 999-999. Enter it in the text field.',
  }
]