Kermit@HP-50g - hp50g.sh
1 #! /bin/sh
2
3
4 function terminate
5 {
6 echo 'Usage:'
7 echo '# hp50g <command>'
8 echo 'Command:'
9 echo '- bye'
10 echo '- dir'
11 echo '- bin'
12 echo '- txt'
13 echo '# hp50g <mode> <file> [<file2> [<file3> ... ]]'
14 echo 'Mode:'
15 echo '- p, s, t (put, send, transmit = PC-->HP50g)'
16 echo '- g, r (get, receive = HP50g-->PC)'
17 exit
18 }
19
20
21 function operate
22 {
23 echo -e "$1\nquit" | kermit
24 echo
25 }
26
27
28 function operate_flag35
29 {
30 operate "remote host -35. $1"
31 }
32
33
34 if test "$#" -lt 2
35 then
36 if test "$#" -ne 1
37 then
38 terminate
39 fi
40 case "$1" in
41 bye) operate "bye" ;;
42 dir) operate "remote dir" ;;
43 bin) operate_flag35 "SF" ;;
44 txt) operate_flag35 "CF"
45 operate "remote host 3 TRANSIO" ;;
46 *) terminate
47 esac
48 exit
49 fi
50 case "$1" in
51 p|s|t)
52 shift
53 for fil in "$@"
54 do
55 if [ ! -f $fil ]
56 then
57 echo "$fil - file not found!"
58 exit
59 fi
60 done
61 operate "msend $*"
62 ;;
63
64 g|r)
65 shift
66 for fil in "$@"
67 do
68 operate "get $fil"
69 done
70 ;;
71
72 *)
73 terminate
74 esac