LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Condition field Ina bash script (https://www.linuxquestions.org/questions/programming-9/condition-field-ina-bash-script-4175717464/)

boughtonp 10-24-2022 11:23 AM

Quote:

Originally Posted by Mobianuser (Post 6384744)
I will check it but I am inside city for the weekend an I need to go country side to better get a gps fix

Not sure if this is still an issue, but for testing purposes perhaps you can replace your GPS program with something that reads an existing data file and pauses between outputting each line, e.g:
Code:

$ cat ./slow-print.sh
#!/bin/bash

while IFS= read -r line; do
    printf '%s\n' "$line";
    sleep 0.5;
done < "$1"

$ ./slow-print.sh sample-data.txt


Mobianuser 10-24-2022 03:56 PM

Something like
/Code
while not grep -iw "longitude" sudo mmcli m --location-get
Do
sudo mmcli m --location-get
Else
Get longitud value
Done
/Code
This is the idea but zI o it thinkis well coded

MadeInGermany 10-30-2022 12:31 PM

Something like this:
Code:

longitude= altitude=
while
  read -r line &&
  [ -z "$longitude" -o -z "$altitude" ]
do
  case $line in
  ( *longitude* )
    longitude=$line
  ;;
  ( *altitude* )
    altitude=$line
  esac
done < <( command_to_process )
printf "%s\n" "$longitude" "$altitude"

This runs the "command_to_process" once,
and reads its output until longitude and altitude occurs.

The alternative is to run a command many times, each time checking if the expected output occurs.


All times are GMT -5. The time now is 03:25 AM.