1998-03-23 10:12:13 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Written by Christofer Edvardsen <ce@earthling.net>, Feb 1998
|
|
|
|
#
|
|
|
|
# This script makes it possible to view and copy files to/from a hp48
|
|
|
|
# (tested with a HP48G and the emulator x48)
|
1998-03-26 09:05:44 +03:00
|
|
|
#
|
|
|
|
# To use the hp48 external filesystem:
|
|
|
|
# - read the relevant parts of your HP48 manual
|
|
|
|
# - install kermit
|
|
|
|
# - connect the HP48 to your computer or start x48
|
|
|
|
# - below change the line which reflects the serial device you use
|
|
|
|
# - configure your HP48 (<left shift> - i/o - iopar):
|
|
|
|
# port: wire
|
|
|
|
# baud: 9600
|
|
|
|
# transfer format: binary (fast transfers) or
|
|
|
|
# ascii (editable on the pc)
|
|
|
|
# - start the server on the HP48: <left shift> - i/o - srvr - serve
|
|
|
|
# or the shortcut <right shift> - <right arrow>
|
|
|
|
# - on MC's commandline enter "cd hp48:"
|
|
|
|
#
|
1998-03-23 10:12:13 +03:00
|
|
|
# Make sure you have kermit installed and that it's using the right serial
|
|
|
|
# device by changing /dev/ttyXX on the next line
|
2002-12-14 05:46:03 +03:00
|
|
|
AWK=@AWK@
|
1998-03-23 10:12:13 +03:00
|
|
|
KERMIT="kermit -l /dev/ttyS1 -b 9600"
|
|
|
|
|
|
|
|
hp48_cmd()
|
|
|
|
{
|
2004-10-18 14:16:26 +04:00
|
|
|
$KERMIT -C "SET EXIT WARNING OFF,REMOTE $1,QUIT"
|
1998-03-23 10:12:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
hp48_cd()
|
|
|
|
{
|
|
|
|
(echo SET EXIT WARNING OFF;echo REMOTE HOST HOME
|
2004-10-18 06:20:09 +04:00
|
|
|
for HP48_DIR in `echo "$1" | tr '/' ' '`;do
|
2004-10-17 23:33:55 +04:00
|
|
|
if [ "x$HP48_DIR" != "x." ];then echo REMOTE HOST "$HP48_DIR"; fi
|
1998-03-23 10:12:13 +03:00
|
|
|
done
|
|
|
|
echo QUIT)| $KERMIT -B >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
hp48_retdir()
|
|
|
|
{
|
2004-10-17 23:33:55 +04:00
|
|
|
echo "$1"
|
1998-03-23 10:12:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
hp48_retsize()
|
|
|
|
{
|
2004-10-17 23:33:55 +04:00
|
|
|
printf "%d" "$2" 2>/dev/null
|
1998-03-23 10:12:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
hp48_parser()
|
|
|
|
{
|
|
|
|
HP48_DIRS=
|
2004-10-17 23:33:55 +04:00
|
|
|
read -r INPUT
|
|
|
|
while [ "x$INPUT" != "xEOF" ]
|
1998-03-23 10:12:13 +03:00
|
|
|
do
|
2004-10-17 23:33:55 +04:00
|
|
|
case `echo "$INPUT" | $AWK '{if (int($2)) if ($3 == "Directory") print "dir";else print "file"}'` in
|
|
|
|
dir) HP48_DIRS="$HP48_DIRS `hp48_retdir \"$INPUT\"`"
|
|
|
|
printf "drwxr-xr-x 1 %-8d %-8d %8d %s %s\n" 0 0 `hp48_retsize "$INPUT"` "`date +\"%b %d %Y %k:%M\"`" "$HP48_CDIR/`hp48_retdir \"$INPUT\"`";;
|
|
|
|
file) printf "-rw-r--r-- 1 %-8d %-8d %8d %s %s\n" 0 0 `hp48_retsize "$INPUT"` "`date +\"%b %d %Y %k:%M\"`" "$HP48_CDIR/`hp48_retdir \"$INPUT\"`";;
|
1998-03-23 10:12:13 +03:00
|
|
|
esac
|
2004-10-17 23:33:55 +04:00
|
|
|
read -r INPUT
|
1998-03-23 10:12:13 +03:00
|
|
|
done
|
2004-10-17 23:33:55 +04:00
|
|
|
for HP48_DIR in $HP48_DIRS;
|
|
|
|
do
|
|
|
|
HP48_PDIR="$HP48_CDIR"
|
2004-10-18 14:16:26 +04:00
|
|
|
HP48_CDIR="$HP48_CDIR/$HP48_DIR"; hp48_cmd "HOST $HP48_DIR" >/dev/null
|
2004-10-17 23:33:55 +04:00
|
|
|
hp48_list
|
2004-10-18 14:16:26 +04:00
|
|
|
HP48_CDIR="$HP48_PDIR"; hp48_cmd "HOST UPDIR" >/dev/null
|
1998-03-23 10:12:13 +03:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
hp48_list()
|
|
|
|
{
|
2004-10-18 14:16:26 +04:00
|
|
|
{ hp48_cmd "DIRECTORY"; echo; echo EOF; } | hp48_parser
|
1998-03-23 10:12:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# override any locale for dates
|
|
|
|
LC_ALL=C
|
|
|
|
export LC_ALL
|
|
|
|
|
2004-10-18 06:20:09 +04:00
|
|
|
case "$1" in
|
1998-03-23 10:12:13 +03:00
|
|
|
list) HP48_CDIR=
|
2004-10-18 14:16:26 +04:00
|
|
|
hp48_cmd "HOST HOME" >/dev/null
|
1998-03-23 10:12:13 +03:00
|
|
|
hp48_list
|
|
|
|
exit 0;;
|
|
|
|
copyout)
|
2004-10-18 06:20:09 +04:00
|
|
|
cd "`dirname "$4"`"
|
|
|
|
hp48_cd "`dirname "$3"`"
|
|
|
|
$KERMIT -B -g "`basename "$3"`" -a "$4" >/dev/null
|
1998-03-23 10:12:13 +03:00
|
|
|
exit 0;;
|
|
|
|
copyin)
|
2004-10-18 06:20:09 +04:00
|
|
|
cd "`dirname "$4"`"
|
|
|
|
hp48_cd "`dirname "$3"`"
|
|
|
|
$KERMIT -B -s "$4" -a "`basename "$3"`" >/dev/null
|
1998-03-23 10:12:13 +03:00
|
|
|
exit 0;;
|
|
|
|
esac
|
|
|
|
exit 1
|