You want to install w3m. It is a text browser. Don’t forget rpi-rw before installing anything if you’re on Pi-Star.

1$ sudo apt-get -y install w3m

The script

The script itself does not verify the given callsign, so whatever you write as an argument, it will be passed to the website. The script returns with 0 if nothing is found.

 1# file: "~/bin/call"
 2#!/bin/bash
 3# Get DMR-IDs from CALLSIGN or CALLSIGN from DMR-ID or vice versa
 4# Author: Dominic Reich, OE7DRT
 5# File:   ~/bin/call
 6#
 7# Last modified: 2020-04-12 13:26:36+0200
 8#
 9# Inspired from this beautiful article:
10#   https://pretzelhands.com/posts/command-line-flags
11#
12# Good DX and vy 73 de OE7DRT
13
14command -v w3m > /dev/null 2>&1 || { echo >&2 "w3m not found"; exit 1; }
15
16print_usage () {
17  echo >&2 "usage: `basename $0` [dmr_id | callsign]"
18  exit 1
19}
20
21if [ $# -ne 1 ]
22then
23  print_usage
24fi
25
26getID () {
27  CALL=`echo $1 | tr a-z A-Z`
28  FILE=/tmp/$CALL
29  w3m "https://ham-digital.org/dmr-userreg.php?callsign=$CALL" > $FILE
30  c=`grep $CALL $FILE | wc -l | xargs`
31
32  while [ $c -gt 0 ]
33  do
34    OUT=`grep $CALL $FILE | head -n $c | tail -n 1 | awk '{ print $4,$5,$2,$3 }'`
35    echo "$OUT"
36    ((c--))
37  done
38  rm $FILE
39}
40
41getCALLSIGN () {
42  ID=$1
43  FILE=/tmp/$ID
44  w3m "https://ham-digital.org/dmr-userreg.php?usrid=$ID" > $FILE
45  CALL=`grep $ID $FILE | awk '{ print $4 }'`
46  rm $FILE
47  if [ -z $CALL ]
48  then
49    exit 1
50  fi
51  getID $CALL
52}
53
54checkID () {
55  if [[ ! $1 =~ ^[0-9]{7}$ ]]
56  then
57    echo >&2 "no valid dmr_id supplied"
58    exit 1
59  fi
60}
61
62if [ "$1" -eq "$1" ] 2>/dev/null
63then
64  ID="$1"
65  checkID $ID
66else
67  CALL="$1"
68fi
69
70if [ ! -z $ID ]
71then
72  getCALLSIGN $ID
73  exit 0
74elif [ ! -z $CALL ]
75then
76  getID $CALL
77  exit 0
78else
79  print_usage
80fi
note
If someone has two DMRIDS, the most recent registered callsign will appear on the top. Feel free to modify the script to your needs if you also want to display the date of registration. Or modify the url if you want to only display last heard ids.

Example usage

Simply get one DMRID (or two, depends on the callsign though):

1$ call OE7DRT

Now let’s think a bit more complex. You can use the script in a loop. Let’s fetch some austrian callsigns only.

1$ for i in 7one 7two 1three; do call oe$i ids >>! ids; done

That would fetch 3 callsigns OE7ONE, OE7TWO and OE1ONE and write them all into the file ids. So run cat ids and display them on screen. Or copy them into clipboard (on a mac only) with pbcopy < ids.

1OE7ONE Username1 0007001 2018-05-12
2OE7TWO Username2 0007003 2018-12-08
3OE7TWO Username2 0007002 2018-11-09
4OE1ONE Username3 0001001 2020-03-13

I’ve been anonymizing the data a bit.

Partially known callsign

I anonymized some DMR-IDs on this website.

So you know only the three last letters of an austrian callsign and want to know quickly what federal state it was? Run this command and you’ll get a quick answer on the command line:

1$ for i in oe{1..9}drt; do call $i; done
2OE7DRT Dominic 2327180 2019-11-24

If you called your script call and if call is in your $PATH.

This works also if you missed one letter.

1$ for i in oe7{a..z}rt; do call $i; done
2OE7BRT Rainer 2327XXX 20XX-XX-XX
3OE7DRT Dominic 2327180 2019-11-24
4OE7JRT Josef 2327XXX 20XX-XX-XX

This took ~10 seconds on my computer.

Or even with more letters, but this will take a while, since this will start 676 (26x26) website lookups to ham-digital.org—maybe they’ll block your IP address quickly, if you hammer their server with so many request in a short period of time.

1$ for i in oe7d{a..z}{a..z}; do call $i; done
22327XXX OE7D?? Daniel
32327XXX OE7D?? Hermann
42327XXX OE7D?? Josef
52327XXX OE7D?? Dragan
62327XXX OE7D?? Peter
72327180 OE7D?? Dominic
82327XXX OE7D?? Wechselberger
92327XXX OE7D?? Gernot

And this ran for 3 minutes and 17 seconds on my computer.

note
The output above was made with an older version of the script. The output now contains also the registration date as seen in previous examples.