km4ack / Pi-APRS

packet program designed to communicate with ISS via APRS
GNU General Public License v3.0
16 stars 4 forks source link

Fix City name with spaces #3

Open km4ack opened 3 years ago

km4ack commented 3 years ago

I couldn’t get my city name, Laguna Beach, to stick in the settings. It caused an error during Pi-APRS startup:

/home/pi/Pi-APRS/config: line 7: Beach: command not found

Then the City was blank when I opened the Settings dialog.

I fixed that by patching line 161 in the functions file to:

CITY=\'$(echo $SETTING | awk -F "|" '{print$3}')\'

So now the city name sticks in settings. The config file has:

CITY='Laguna Beach'

And my Heard You packets look good:

2021-03-08 10:04:20 PST: KW6REX>WIDE2-2,qAR,AVALN::KW6REX :Heard you via ISS in Laguna Beach, CA DM13

73,

Rex

KW6REX

km4ack commented 3 years ago

Jason,

In the bug (https://github.com/km4ack/Pi-APRS/issues/3) it has the fix as

CITY='$(echo $SETTING | awk -F "|" '{print$3}')'

But you need the \ (escape) characters that I showed before the first and last single-quote:

CITY=\'$(echo $SETTING | awk -F "|" '{print$3}')\'

Without them it treats the text between the quotes as literal and you end up with CITY equal to the text of the expression instead of the result of the expression, the actual city name enclosed in quotes:

pi@raspberrypi:~ $ SETTING="KW6REX|10|Laguna Beach"

pi@raspberrypi:~ $ CITY='$(echo $SETTING | awk -F "|" '{print$3}')'

pi@raspberrypi:~ $ echo $CITY

$(echo $SETTING | awk -F "|" {print})

pi@raspberrypi:~ $ CITY=\'$(echo $SETTING | awk -F "|" '{print$3}')\'

pi@raspberrypi:~ $ echo $CITY

'Laguna Beach'

Rex

KW6REX