SDS100/SDS200: sds200, ftp, directory listing & names

n1moy

Member
Joined
Oct 19, 2022
Messages
68
Location
Plymouth Co, Massachusetts
Greetings!

Have been scrutinizing the directory listing from the sds200 ftp server.

227 Entering Passive Mode (192,168,24,40,4,27)
150 Opening data connection.
d--------- 1 owner nogroup 0 Jan 12 20:14 .
d--------- 1 owner nogroup 0 Jan 12 20:14 ..
d--------- 1 owner nogroup 0 Jan 25 12:22 583962D7
d--------- 1 owner nogroup 0 Jan 25 14:42 58397550
d--------- 1 owner nogroup 0 Jan 25 15:46 58397DCE
d--------- 1 owner nogroup 0 Jan 25 16:43 58398564
d--------- 1 owner nogroup 0 Jan 25 17:54 58398ED6
d--------- 1 owner nogroup 0 Jan 25 19:34 58399C5A
d--------- 1 owner nogroup 0 Jan 25 20:49 5839A623
d--------- 1 owner nogroup 0 Jan 25 22:06 5839B0D1
d--------- 1 owner nogroup 0 Jan 26 00:23 583A02F3
d--------- 1 owner nogroup 0 Jan 26 02:52 583A1699
226 Transfer complete.

The hexadecimal directory names are perhaps a timestamp ?

Looking for methods to generate or read the name. Seeking any related documentation.

Thanks in advance,
 

belvdr

No longer interested in living
Joined
Aug 2, 2013
Messages
2,567
Looks like epoch time converted to hex.
 

JoeBearcat

Active Member
Uniden Representative
Joined
Jun 30, 2020
Messages
1,967
Looks like it corresponds pretty well short a 9 minute time difference. (assuming you are in the Eastern time zone)
 

n1moy

Member
Joined
Oct 19, 2022
Messages
68
Location
Plymouth Co, Massachusetts
Composed a Bash script on my Linux machine for the directory analysis.

uniden-directory.sh

Displays sorted directories in /audio/user_rec

Bash:
#!/bin/bash

# uniden-directory.sh
# Bash script to read sds200/microSD directories. - n1moy

RADIO="192.168.24.40"    # IP address
READ="read.user"         # read only user
RPASSWD="password"       # password-read

SESSION=`ftp -inv <<ROUT
open $RADIO
user $READ $RPASSWD
cd /audio/user_rec
ls
bye
ROUT`

gawk '{if ($1 ~ /^d-{9}/ && ($9 !~ /\.{1,2}/)) \
print $6, $7, $8, $9}' <<< "$SESSION" | sort -dk9
exit
 
Last edited:

n1moy

Member
Joined
Oct 19, 2022
Messages
68
Location
Plymouth Co, Massachusetts
Laughable error ... posted the wrong version!
Here is the correct one.


Bash:
#!/bin/bash

# uniden-directory.sh
# Bash script to read sds200/microSD directories. - n1moy

RADIO="192.168.24.40"    # IP address
READ="read.user"         # read only user
RPASSWD="password"       # password-read

SESSION=`ftp -inv <<ROUT
open $RADIO
user $READ $RPASSWD
cd /audio/user_rec
ls
bye
ROUT`

DIR_LIST=$(echo "$SESSION" | sort -dk9)

gawk '{if ($1 ~ /^d-{9}/ && ($9 !~ /\.{1,2}/)) \
print $6, $7, $8, $9 }'  <<< "$DIR_LIST"
exit
 
Last edited:

belvdr

No longer interested in living
Joined
Aug 2, 2013
Messages
2,567
Great work! I have a couple of suggestions.

Make the environment variables read from command-line parameters, make the variable names friendlier/more descriptive, and create a usage function. Something like this:
Code:
if [ "$#" -ne "3" ]; then
   echo "Usage:"
   echo "   uniden_directory.sh <IP> <FTP read username> <FTP read password>"
   exit 1
else
   IP="$1"
   USERNAME="$2"
   PASSWORD="$3"
fi
This checks for exactly 3 parameters given. If there aren't, it outputs how to use the program and exits. Otherwise, it assigns those parameters into the variables. Then you'd run it with:
Code:
./uniden-directory.sh 192.168.24.40 read.user password
The next suggestion (and I need to do this on my own projects too) is to use Python. It not only has the capability, but also the portability to run on a wide number of platforms, including Windows and macOS. As it stands today, this script only works on platforms with the GNU utilities available. I'll see if I can get something going, although it may be a bit, as my SDS is not on the LAN at the moment.
 

belvdr

No longer interested in living
Joined
Aug 2, 2013
Messages
2,567
Here's a Python script, tested with 3.11.6. In this code, the usage will always output whatever the script is named.
Code:
import ftplib
import sys

SCRIPT_NAME = sys.argv[0]

# We require 3 command line parameters.  Since argv[0] is one of those, we test for 4
if len(sys.argv) != 4:
    # Echo usage and exit with status 1
    print(SCRIPT_NAME, "<IP> <FTP Read Username> <FTP Read Password>")
    sys.exit(1)

# Grab the data from the command line
FTP_HOST = sys.argv[1]
FTP_USER = sys.argv[2]
FTP_PASS = sys.argv[3]

# Initialize an array for the directory listing
DIR_LIST = []

# Start FTP session
ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)

# Force UTF-8 encoding
ftp.encoding = "utf-8"

# List the recording directory into a variable
ftp.dir("/audio/user_rec/", DIR_LIST.append)

# We have our data, so let's clost the FTP connection
ftp.quit()

# Loop through the directory listing
for LINE in DIR_LIST:
    # If the line starts with "d", then it's a directory
    if LINE.startswith("d"):
        # Split the line by spaces and grab the last item on the line, the directory name
        DIR_NAME = LINE.split()[-1]
        try:
            # Try to convert the directory name to an integer, using Base-16.  If successful, then it's a valid hexadecimal number, so print it.
            if int(DIR_NAME, 16):
                print(DIR_NAME)
        except:
            # Ignore any exceptions, as they are not valid hexadecimal numbers.
            pass
 

n1moy

Member
Joined
Oct 19, 2022
Messages
68
Location
Plymouth Co, Massachusetts
Thanks for your comments and suggestions!

As a start, had already ordered a couple of Python books. May use this endeavor as part of that study. Are sending User Datagram Protocol commands problematic with Python ?

Plug the scanner into your LAN!
 

belvdr

No longer interested in living
Joined
Aug 2, 2013
Messages
2,567
Thanks for your comments and suggestions!

As a start, had already ordered a couple of Python books. May use this endeavor as part of that study. Are sending User Datagram Protocol commands problematic with Python ?

Plug the scanner into your LAN!
I have not tried sending commands in Python similar to netcat. I did get my SDS connected and the script was tested against it.
 

belvdr

No longer interested in living
Joined
Aug 2, 2013
Messages
2,567
Thanks for your comments and suggestions!

As a start, had already ordered a couple of Python books. May use this endeavor as part of that study. Are sending User Datagram Protocol commands problematic with Python ?

Plug the scanner into your LAN!
See your other thread. I posted a Python3 script for sending commands via TCP or UDP.
 
Top