0

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.

  • 1
    i.e. use "/var/spool/gammu/inbox/$1". See also http://mywiki.wooledge.org/WordSplitting – ilkkachu Apr 09 '21 at 10:04
  • I tried this before, but both sed and cat cannot use name like this. That is why I posted a question here. my script looks like

    sed -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
  • ok. can you please [edit] your question to show the whole script, and how you run it? Comments don't allow for proper formatting, and at least I can't make anything out of a script pasted in them because of that. – ilkkachu Apr 09 '21 at 11:15

0 Answers0