NASutils Knowledge BaseUnofficialPolski

The programs of the lessons

120 short programs in BASIC, Pascal, Go and Bash, 30 in each language. Each one ran on a QNAP NAS.

Programming on the NAS

All 120 programs

Download the archive (40 KB)

The archive has each program, the commands that ran it (.session), what the terminal showed (.out), the sample files and the script that runs the programs again. Where a number or a date changes from run to run, a .vary file says which.

Check them yourself

Unpack the archive in a folder of a share and run the script on a NAS with TurboShell. It runs each program in a folder of its own and compares what it prints with the kept output.

tar xzf turboshell-lessons.tar.gz
cd turboshell-lessons
./tools/run-examples.sh basic pascal bash

The Go programs first become files in go-bin, with Go on the path: run bash tools/build-go.sh in Bucket & Code, then ./tools/run-examples.sh go on the NAS.

BASIC

Pascal

Go

Bash

The sample files

Some programs read these files. Copy each one into the folder of your lessons.

nas.log

2027-01-04 02:00:01 INFO backup started
2027-01-04 02:14:37 INFO backup finished
2027-01-04 08:31:12 WARN disk 3 temperature 51
2027-01-04 09:02:44 ERROR share Documents is full
2027-01-05 02:00:01 INFO backup started
2027-01-05 02:03:10 ERROR backup stopped: no space
2027-01-05 02:03:10 WARN free space below 5 percent
2027-01-05 11:47:29 INFO admin signed in
2027-01-06 02:00:01 INFO backup started
2027-01-06 02:13:58 INFO backup finished
2027-01-06 14:20:05 WARN disk 3 temperature 53
2027-01-06 18:09:33 ERROR disk 3 read error

disks.csv

slot,model,size_gb,temp_c
1,Example HDD A,8000,38
2,Example HDD A,8000,39
3,Example HDD B,12000,53
4,Example SSD C,1000,44

smartctl.txt

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       8
  9 Power_On_Hours          0x0032   071   071   000    Old_age   Always       -       26280
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       64
194 Temperature_Celsius     0x0022   112   098   000    Old_age   Always       -       38
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       2

df.txt

Filesystem     1024-blocks       Used  Available Capacity Mounted on
/dev/data1      7751370240 5813527680 1937842560      75% /volume/data
/dev/data2      3875685120 3604387161  271297959      93% /volume/media
/dev/fast1       976762584  195352516  781410068      20% /volume/fast

config.ini

[report]
title=Morning check
limit=90

[backup]
folder=backups
keep=3

words.txt

The NAS keeps files.
The files live on disks.
Disks fail, so keep a copy of the files.

The folder photos has six files of fixed sizes. These commands make it:

mkdir -p photos
for f in 4200:beach.jpg 900:cat.jpg 15800:wedding.mov 2600:garden.jpg 7300:trip.mp4 120:notes.txt; do
  head -c "${f%%:*}" /dev/zero > "photos/${f#*:}"
done