Skip to content

Commit

Permalink
treehouses remote reverse better json (fixes #2149) (#2150)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
JLKwong and dogi authored Apr 15, 2021
1 parent 1293ef7 commit f23b467
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions modules/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ function remote {
;;
"reverse")
checkargn $# 2
reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f 2,3,4 | sed 's#\:[[:space:]]\"#:\"#g' | awk '!x[$0]++')
reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f 2,3,4 | sed 's#\:[[:space:]]\"#:\"#g')
while IFS= read -r line; do
cmd_str+="\"$line\","
done <<< "$reverse"
ip=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 1)
org=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 2)
country=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 3)
city=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 4)
postal=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 5)
timezone=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 6)
ip=$(echo "$reverse" | grep 'ip":"')
org=$(echo "$reverse" | grep 'org":"')
country=$(echo "$reverse" | grep 'country":"')
city=$(echo "$reverse" | grep 'city":"')
postal=$(echo "$reverse" | grep 'postal":"')
timezone=$(echo "$reverse" | grep 'timezone":"')

echo "{$ip,$org,$country,$city,$postal,$timezone}"
echo "{\"$ip\",\"$org\",\"$country\",\"$city\",\"$postal\",\"$timezone\"}"
;;
"allservices")
checkargn $# 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.25.40",
"version": "1.25.41",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit f23b467

Please sign in to comment.