I am using Gammu for receiving SMS. Once received I am sending them as emails. Yet if sender ID of the SMS contains space, my script is unable to process a file. I.e.:
If the file name is IN20210409_104439_00_SOME NAME_00.txt runonreceive script uses $1 to handle the filename but it saves only IN20210409_104439_00_SOME and obviously such file doesn't exist which brings errors.
runonreceive script:
sed -i '1 i\Subject: Incoming sms\n\n' /var/spool/gammu/inbox/$1
cat /var/spool/gammu/inbox/$1 | msmtp desrired@email.com
So I am looking for a solution for handling full filename (with spaces) or to rename the file in that script (on-the-fly) and send out renamed SMS as email.
"/var/spool/gammu/inbox/$1"
. See also http://mywiki.wooledge.org/WordSplitting – ilkkachu Apr 09 '21 at 10:04sed -i '1 i\Subject: Incoming sms\n\n' "/var/spool/gammu/inbox/$1" cat "/var/spool/gammu/inbox/$1" | msmtp desired@email.com
but after excuting scirpt: /var/spool/gammu/mail_wrapper.sh IN20210409_104527_00_SOME NAME_00.txt
sed: nie można odczytać /var/spool/gammu/inbox/IN20210409_104527_00_SOME: Nie ma takiego pliku ani katalogu
which basically in my languuage means, couldn't read /var/spool/gammu/inbox/IN20210409_104527_00_SOME: No such file
– ŁukaszI Apr 09 '21 at 11:13