fixed APN to fetch the third field directly
This commit is contained in:
@@ -62,8 +62,7 @@ MODEM_MODEL=$(</tmp/modemmodel.txt)
|
||||
MODEM_MODEL=$(echo "$MODEM_MODEL" | grep -o "RG[^ ]\+\|RM[^ ]\+")
|
||||
|
||||
# Get the APN from /tmp/apn.txt and parse it
|
||||
APN=$(</tmp/apn.txt)
|
||||
APN=$(echo "$APN" | grep -o '"[^"]*"' | head -n1 | tr -d '"')
|
||||
APN=$(grep "^+CGCONTRDP" /tmp/apn.txt | awk -F',' '{gsub(/"/, "", $3); print $3}')
|
||||
|
||||
# Get the SIM slot from /tmp/simslot.txt and parse it
|
||||
# simslot.txt looks like this: +QUIMSLOT: 1
|
||||
|
||||
0
simpleadmin/scripts/test.json
Normal file
0
simpleadmin/scripts/test.json
Normal file
@@ -8,6 +8,7 @@ file_name="$1"
|
||||
|
||||
echo "{"
|
||||
last_line=$(wc -l < "$file_name")
|
||||
first_line=true
|
||||
|
||||
while IFS='=' read -r key value || [[ -n "$key" ]]; do
|
||||
# Skip empty lines and comments
|
||||
@@ -26,15 +27,22 @@ while IFS='=' read -r key value || [[ -n "$key" ]]; do
|
||||
value="\"$value\""
|
||||
fi
|
||||
|
||||
# Print key-value pair in JSON format without surrounding double quotes on value
|
||||
printf ' "%s" : %s' "$key" "$value"
|
||||
# Check if value is empty, if so, skip printing this key-value pair
|
||||
if [[ -z "$value" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if not the last line, add comma
|
||||
if [ $((++current_line)) -lt "$last_line" ]; then
|
||||
# Print comma before each pair except for the first one
|
||||
if $first_line; then
|
||||
first_line=false
|
||||
else
|
||||
printf ','
|
||||
fi
|
||||
|
||||
# Print key-value pair in JSON format without surrounding double quotes on value
|
||||
printf ' "%s" : %s' "$key" "$value"
|
||||
|
||||
printf '\n'
|
||||
done < "$file_name"
|
||||
|
||||
echo "}"
|
||||
echo "}"
|
||||
|
||||
Reference in New Issue
Block a user