I have written a BASH Shell Script for linking to reflectors via the command line. Below is a screen capture showing the output of the script:
The script is shown in the code block below:
Code: Select all
#!/bin/bash
####################################
#
# Script to link to Dstar reflector
#
# Scott Showalter - N7HHI - 10/06/2018
#
####################################
# ${0} is the script name
# $(basename ${0}) strips the first portion of the PATH so that only the script name is returned
# ${1} is the number of the reflector
# ${2} is the port of the reflector
#
if [ $# -ne 2 ]; then
echo "Usage: $(basename ${0}) [number] [port]"
echo ""
echo "[number] = reflector number"
echo "[port] = Alphabetic port representation [a-z] (not case sensitive)"
echo "e.g. ref 001 c - in order to link to ref001 C"
echo "e.g. dcs 757 a - in order to link to dcs757 A"
echo "e.g. xrf 307 d - in order to link to xrf307 D"
echo ""
exit 1
fi
# Set RDX to lowercase Reflector type
RDX="$(echo $(basename ${0}) | tr '[A-Z]' '[a-z]')"
# Set REPN to Repeter Number padded to 3 characters
# If user enters less than 3 digits, pad with leading zeros to total 3 characters
REPN=$(printf "%03d" ${1})
# Set PORT to lowercase Port, in order to make the entry case-insensitive
PORT="$(echo ${2} | tr '[A-Z]' '[a-z]')"
# Link to Reflector and redirect stdout and stderr to /dev/null
sudo pistar-link ${RDX}${REPN}_${PORT} >/dev/null 2>&1
# Wait 1 second. This is needed for the linked repeater to show up in the
# /var/log/pi-star/Links.log file prior to displaying it.
sleep 1
#Display the linked to reflector as determined from /var/log/pi-star/Links.log
echo "Linked to $(awk '{print $12, $13}' /var/log/pi-star/Links.log)"
I created this script as /home/pi-star/bin/ref.
- Go into Read/Write mode: rpi-rw
- Make the directory to store the script (in my case, I called it bin): mkdir /home/pi-star/bin
- Change to the bin directory: cd /home/pi-star/bin
- Copy the above script to the new directory and call it by one of the names for the type of reflector: nano ref
- Paste the contents into the nano editor. Save the file: CTRL O
- Press [Enter] to accept the default name you specified when opening the editor: [Enter]
- Exit the editor: CTRL X
- Give execute permissions to the script: chmod 755 /home/pi-star/bin/ref
If you want to be able to just type ref 001 c, then you need to add /home/pi-star/bin to your PATH environment variable. To do that edit the /home/pi-star/.bashrc file and add the following lines to it:
Code: Select all
PATH=${PATH}:/home/pi-star/bin
Next create the additional links for the DPlus and DCS reflectors:
Code: Select all
ln ref xrf
ln ref dcs
Code: Select all
xrf 307 d
dcs 757 a
Code: Select all
ln ref REF
ln ref XRF
ln ref DCS
Code: Select all
pi-star@pi-star(rw):bin$ ls -l
total 24
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 dcs
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 DCS
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 ref
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 REF
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 xrf
-rwxrw-rw- 6 pi-star pi-star 1406 Oct 6 13:10 XRF
To link to XRF307 D, you can enter XRF 307 D or xrf 307 d
To link to DCS757 A, you can enter DCS 757 A or dcs757 a
Put pi-star back into Read Only mode: rpi-ro
**** Moderators Edit ****
Great that you are writing scripts and putting then up on the board, and not wanting to take away from the work you have done, but
Pistar has the ability to link from the command line written in, using Pistar-link.
**** Moderators Edit ****