Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/deluser

StarterPak/!Newsbase/Transports/taylor/deluser

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet
Filename: StarterPak/!Newsbase/Transports/taylor/deluser
Read OK:
File size: 072C bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >deluser
   20REM delete a user from the /etc/passwd file, whereever it is.
   30REM
   40REM Author:         Gunnar ZREPORTtl
   50REM Date:           18-Sep-1994
   60REM Last modified:  06-Nov-1994
   70
   80ONERROR REPORT:PRINT" at line ";ERL:END
   90
  100LIBRARY "<NewsBase$TaylorDir>.ScriptLib"
  110
  120REM default value for group
  130GRP% = 1
  140
  150REM get command line parameters
  160PROCentry
  170IF (argc = 3) THEN
  180    IF argv$(1) = "-u" THEN
  190        N$ = argv$(2)
  200    ELSE
  210        PROCexit(1, "Invalid Parameters")
  220    ENDIF
  230ELSE
  240    PROCexit(1, "Invalid Parameters")
  250ENDIF
  260
  270REM remove spaces from username.
  280user$ = FNstripspaces(N$)
  290user$ = FNtolower(user$) + ":"
  300
  310IF FNgetenv("Wimp$ScrapDir") = "" THEN
  320    PROCexit(0, "ScrapDir must have been seen")
  330ENDIF
  340etcpasswd$ = FNupath("/etc/passwd")
  350etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd")
  360cdiff = ASC"a" - ASC"A"
  370
  380REM we copy the passwd file to a scrapfile line by line,
  390REM omitting the line that has our user.
  400if% = OPENIN(etcpasswd$)
  410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd")
  420of% = OPENOUT(etcbpasswd$)
  430IF of% = 0 THEN PROCexit(1, "could not open <Wimp$ScrapDir>.passwd")
  440l% = LEN(user$)
  450REPEAT
  460    c$ = GET$#if%
  470    IF user$ <> FNtolower(LEFT$(c$, l%)) THEN BPUT #of%,c$
  480UNTIL c$ = ""
  490CLOSE #of%
  500CLOSE #if%
  510OSCLI("settype " +etcbpasswd$ + " FFF")
  520
  530REM now copy our new file over the old one then exit and tell
  540REM NewsBase that all went fine.
  550OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
  560PROCexit(0, "user added")
  570END
  580
  590REM convert all characters in a string to lowercase.
  600REM
  610DEF FNtolower(a$)
  620LOCAL i%, c$
  630FOR i% = 1 TO LENa$
  640    c$ = MID$(a$, i%, 1)
  650    IF c$ >= "A" AND c$ <= "Z" THEN
  660        MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff)
  670    ENDIF
  680= a$
  690
  700REM exit from here, returning appropriate info.
  710REM
  720DEFPROCexit(n%,a$)
  730OSCLI("set NewsBase$ReturnCode "+STR$n%)
  740OSCLI("set NewsBase$ReturnInfo "+a$)
  750END
  760ENDPROC

� >deluser
?� delete a user from the /etc/passwd file, whereever it is.
�
(!� Author:         Gunnar Z�tl
2!� Date:           18-Sep-1994
<!� Last modified:  06-Nov-1994
F
P� �:�" at line ";�:�
Z
d'ț "<NewsBase$TaylorDir>.ScriptLib"
n
x� default value for group
�GRP% = 1
�
�!� get command line parameters
�
�entry
�� (argc = 3) �
�    � argv$(1) = "-u" �
�        N$ = argv$(2)
�	    �
�*        �exit(1, "Invalid Parameters")
�	    �
��
�&    �exit(1, "Invalid Parameters")
��

"� remove spaces from username.
user$ = �stripspaces(N$)
"!user$ = �tolower(user$) + ":"
,
6%� �getenv("Wimp$ScrapDir") = "" �
@0    �exit(0, "ScrapDir must have been seen")
J�
T&etcpasswd$ = �upath("/etc/passwd")
^2etcbpasswd$ = �upath("<Wimp$ScrapDir>.passwd")
hcdiff = �"a" - �"A"
r
|:� we copy the passwd file to a scrapfile line by line,
�*� omitting the line that has our user.
�if% = �(etcpasswd$)
�6� if% = 0 � �exit(1, "could not open /etc/passwd")
�of% = �(etcbpasswd$)
�A� of% = 0 � �exit(1, "could not open <Wimp$ScrapDir>.passwd")
�l% = �(user$)
��
�    c$ = �#if%
�1    � user$ <> �tolower(�c$, l%)) � � #of%,c$
�
� c$ = ""
�
� #of%
�
� #if%
�'�("settype " +etcbpasswd$ + " FFF")

?� now copy our new file over the old one then exit and tell
"� NewsBase that all went fine.
&;�("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
0�exit(0, "user added")
:�
D
N6� convert all characters in a string to lowercase.
X�
b� �tolower(a$)
l� i%, c$
v� i% = 1 � �a$
�    c$ = �a$, i%, 1)
�!    � c$ >= "A" � c$ <= "Z" �
�*        �a$, i%, 1) = �(�(c$) + cdiff)
�	    �
�= a$
�
�1� exit from here, returning appropriate info.
��
���exit(n%,a$)
�%�("set NewsBase$ReturnCode "+�n%)
�$�("set NewsBase$ReturnInfo "+a$)
��
��
�
00000000  0d 00 0a 0e f4 20 3e 64  65 6c 75 73 65 72 0d 00  |..... >deluser..|
00000010  14 3f f4 20 64 65 6c 65  74 65 20 61 20 75 73 65  |.?. delete a use|
00000020  72 20 66 72 6f 6d 20 74  68 65 20 2f 65 74 63 2f  |r from the /etc/|
00000030  70 61 73 73 77 64 20 66  69 6c 65 2c 20 77 68 65  |passwd file, whe|
00000040  72 65 65 76 65 72 20 69  74 20 69 73 2e 0d 00 1e  |reever it is....|
00000050  05 f4 0d 00 28 21 f4 20  41 75 74 68 6f 72 3a 20  |....(!. Author: |
00000060  20 20 20 20 20 20 20 20  47 75 6e 6e 61 72 20 5a  |        Gunnar Z|
00000070  f6 74 6c 0d 00 32 21 f4  20 44 61 74 65 3a 20 20  |.tl..2!. Date:  |
00000080  20 20 20 20 20 20 20 20  20 31 38 2d 53 65 70 2d  |         18-Sep-|
00000090  31 39 39 34 0d 00 3c 21  f4 20 4c 61 73 74 20 6d  |1994..<!. Last m|
000000a0  6f 64 69 66 69 65 64 3a  20 20 30 36 2d 4e 6f 76  |odified:  06-Nov|
000000b0  2d 31 39 39 34 0d 00 46  04 0d 00 50 19 ee 85 20  |-1994..F...P... |
000000c0  f6 3a f1 22 20 61 74 20  6c 69 6e 65 20 22 3b 9e  |.:." at line ";.|
000000d0  3a e0 0d 00 5a 04 0d 00  64 27 c8 9b 20 22 3c 4e  |:...Z...d'.. "<N|
000000e0  65 77 73 42 61 73 65 24  54 61 79 6c 6f 72 44 69  |ewsBase$TaylorDi|
000000f0  72 3e 2e 53 63 72 69 70  74 4c 69 62 22 0d 00 6e  |r>.ScriptLib"..n|
00000100  04 0d 00 78 1d f4 20 64  65 66 61 75 6c 74 20 76  |...x.. default v|
00000110  61 6c 75 65 20 66 6f 72  20 67 72 6f 75 70 0d 00  |alue for group..|
00000120  82 0c 47 52 50 25 20 3d  20 31 0d 00 8c 04 0d 00  |..GRP% = 1......|
00000130  96 21 f4 20 67 65 74 20  63 6f 6d 6d 61 6e 64 20  |.!. get command |
00000140  6c 69 6e 65 20 70 61 72  61 6d 65 74 65 72 73 0d  |line parameters.|
00000150  00 a0 0a f2 65 6e 74 72  79 0d 00 aa 12 e7 20 28  |....entry..... (|
00000160  61 72 67 63 20 3d 20 33  29 20 8c 0d 00 b4 1b 20  |argc = 3) ..... |
00000170  20 20 20 e7 20 61 72 67  76 24 28 31 29 20 3d 20  |   . argv$(1) = |
00000180  22 2d 75 22 20 8c 0d 00  be 19 20 20 20 20 20 20  |"-u" .....      |
00000190  20 20 4e 24 20 3d 20 61  72 67 76 24 28 32 29 0d  |  N$ = argv$(2).|
000001a0  00 c8 09 20 20 20 20 cc  0d 00 d2 2a 20 20 20 20  |...    ....*    |
000001b0  20 20 20 20 f2 65 78 69  74 28 31 2c 20 22 49 6e  |    .exit(1, "In|
000001c0  76 61 6c 69 64 20 50 61  72 61 6d 65 74 65 72 73  |valid Parameters|
000001d0  22 29 0d 00 dc 09 20 20  20 20 cd 0d 00 e6 05 cc  |")....    ......|
000001e0  0d 00 f0 26 20 20 20 20  f2 65 78 69 74 28 31 2c  |...&    .exit(1,|
000001f0  20 22 49 6e 76 61 6c 69  64 20 50 61 72 61 6d 65  | "Invalid Parame|
00000200  74 65 72 73 22 29 0d 00  fa 05 cd 0d 01 04 04 0d  |ters")..........|
00000210  01 0e 22 f4 20 72 65 6d  6f 76 65 20 73 70 61 63  |..". remove spac|
00000220  65 73 20 66 72 6f 6d 20  75 73 65 72 6e 61 6d 65  |es from username|
00000230  2e 0d 01 18 1c 75 73 65  72 24 20 3d 20 a4 73 74  |.....user$ = .st|
00000240  72 69 70 73 70 61 63 65  73 28 4e 24 29 0d 01 22  |ripspaces(N$).."|
00000250  21 75 73 65 72 24 20 3d  20 a4 74 6f 6c 6f 77 65  |!user$ = .tolowe|
00000260  72 28 75 73 65 72 24 29  20 2b 20 22 3a 22 0d 01  |r(user$) + ":"..|
00000270  2c 04 0d 01 36 25 e7 20  a4 67 65 74 65 6e 76 28  |,...6%. .getenv(|
00000280  22 57 69 6d 70 24 53 63  72 61 70 44 69 72 22 29  |"Wimp$ScrapDir")|
00000290  20 3d 20 22 22 20 8c 0d  01 40 30 20 20 20 20 f2  | = "" ...@0    .|
000002a0  65 78 69 74 28 30 2c 20  22 53 63 72 61 70 44 69  |exit(0, "ScrapDi|
000002b0  72 20 6d 75 73 74 20 68  61 76 65 20 62 65 65 6e  |r must have been|
000002c0  20 73 65 65 6e 22 29 0d  01 4a 05 cd 0d 01 54 26  | seen")..J....T&|
000002d0  65 74 63 70 61 73 73 77  64 24 20 3d 20 a4 75 70  |etcpasswd$ = .up|
000002e0  61 74 68 28 22 2f 65 74  63 2f 70 61 73 73 77 64  |ath("/etc/passwd|
000002f0  22 29 0d 01 5e 32 65 74  63 62 70 61 73 73 77 64  |")..^2etcbpasswd|
00000300  24 20 3d 20 a4 75 70 61  74 68 28 22 3c 57 69 6d  |$ = .upath("<Wim|
00000310  70 24 53 63 72 61 70 44  69 72 3e 2e 70 61 73 73  |p$ScrapDir>.pass|
00000320  77 64 22 29 0d 01 68 17  63 64 69 66 66 20 3d 20  |wd")..h.cdiff = |
00000330  97 22 61 22 20 2d 20 97  22 41 22 0d 01 72 04 0d  |."a" - ."A"..r..|
00000340  01 7c 3a f4 20 77 65 20  63 6f 70 79 20 74 68 65  |.|:. we copy the|
00000350  20 70 61 73 73 77 64 20  66 69 6c 65 20 74 6f 20  | passwd file to |
00000360  61 20 73 63 72 61 70 66  69 6c 65 20 6c 69 6e 65  |a scrapfile line|
00000370  20 62 79 20 6c 69 6e 65  2c 0d 01 86 2a f4 20 6f  | by line,...*. o|
00000380  6d 69 74 74 69 6e 67 20  74 68 65 20 6c 69 6e 65  |mitting the line|
00000390  20 74 68 61 74 20 68 61  73 20 6f 75 72 20 75 73  | that has our us|
000003a0  65 72 2e 0d 01 90 17 69  66 25 20 3d 20 8e 28 65  |er.....if% = .(e|
000003b0  74 63 70 61 73 73 77 64  24 29 0d 01 9a 36 e7 20  |tcpasswd$)...6. |
000003c0  69 66 25 20 3d 20 30 20  8c 20 f2 65 78 69 74 28  |if% = 0 . .exit(|
000003d0  31 2c 20 22 63 6f 75 6c  64 20 6e 6f 74 20 6f 70  |1, "could not op|
000003e0  65 6e 20 2f 65 74 63 2f  70 61 73 73 77 64 22 29  |en /etc/passwd")|
000003f0  0d 01 a4 18 6f 66 25 20  3d 20 ae 28 65 74 63 62  |....of% = .(etcb|
00000400  70 61 73 73 77 64 24 29  0d 01 ae 41 e7 20 6f 66  |passwd$)...A. of|
00000410  25 20 3d 20 30 20 8c 20  f2 65 78 69 74 28 31 2c  |% = 0 . .exit(1,|
00000420  20 22 63 6f 75 6c 64 20  6e 6f 74 20 6f 70 65 6e  | "could not open|
00000430  20 3c 57 69 6d 70 24 53  63 72 61 70 44 69 72 3e  | <Wimp$ScrapDir>|
00000440  2e 70 61 73 73 77 64 22  29 0d 01 b8 11 6c 25 20  |.passwd")....l% |
00000450  3d 20 a9 28 75 73 65 72  24 29 0d 01 c2 05 f5 0d  |= .(user$)......|
00000460  01 cc 12 20 20 20 20 63  24 20 3d 20 be 23 69 66  |...    c$ = .#if|
00000470  25 0d 01 d6 31 20 20 20  20 e7 20 75 73 65 72 24  |%...1    . user$|
00000480  20 3c 3e 20 a4 74 6f 6c  6f 77 65 72 28 c0 63 24  | <> .tolower(.c$|
00000490  2c 20 6c 25 29 29 20 8c  20 d5 20 23 6f 66 25 2c  |, l%)) . . #of%,|
000004a0  63 24 0d 01 e0 0d fd 20  63 24 20 3d 20 22 22 0d  |c$..... c$ = "".|
000004b0  01 ea 0a d9 20 23 6f 66  25 0d 01 f4 0a d9 20 23  |.... #of%..... #|
000004c0  69 66 25 0d 01 fe 27 ff  28 22 73 65 74 74 79 70  |if%...'.("settyp|
000004d0  65 20 22 20 2b 65 74 63  62 70 61 73 73 77 64 24  |e " +etcbpasswd$|
000004e0  20 2b 20 22 20 46 46 46  22 29 0d 02 08 04 0d 02  | + " FFF")......|
000004f0  12 3f f4 20 6e 6f 77 20  63 6f 70 79 20 6f 75 72  |.?. now copy our|
00000500  20 6e 65 77 20 66 69 6c  65 20 6f 76 65 72 20 74  | new file over t|
00000510  68 65 20 6f 6c 64 20 6f  6e 65 20 74 68 65 6e 20  |he old one then |
00000520  65 78 69 74 20 61 6e 64  20 74 65 6c 6c 0d 02 1c  |exit and tell...|
00000530  22 f4 20 4e 65 77 73 42  61 73 65 20 74 68 61 74  |". NewsBase that|
00000540  20 61 6c 6c 20 77 65 6e  74 20 66 69 6e 65 2e 0d  | all went fine..|
00000550  02 26 3b ff 28 22 63 6f  70 79 20 22 20 2b 20 65  |.&;.("copy " + e|
00000560  74 63 62 70 61 73 73 77  64 24 20 2b 20 22 20 22  |tcbpasswd$ + " "|
00000570  20 2b 20 65 74 63 70 61  73 73 77 64 24 20 2b 20  | + etcpasswd$ + |
00000580  22 20 46 44 7e 43 7e 56  22 29 0d 02 30 1a f2 65  |" FD~C~V")..0..e|
00000590  78 69 74 28 30 2c 20 22  75 73 65 72 20 61 64 64  |xit(0, "user add|
000005a0  65 64 22 29 0d 02 3a 05  e0 0d 02 44 04 0d 02 4e  |ed")..:....D...N|
000005b0  36 f4 20 63 6f 6e 76 65  72 74 20 61 6c 6c 20 63  |6. convert all c|
000005c0  68 61 72 61 63 74 65 72  73 20 69 6e 20 61 20 73  |haracters in a s|
000005d0  74 72 69 6e 67 20 74 6f  20 6c 6f 77 65 72 63 61  |tring to lowerca|
000005e0  73 65 2e 0d 02 58 05 f4  0d 02 62 12 dd 20 a4 74  |se...X....b.. .t|
000005f0  6f 6c 6f 77 65 72 28 61  24 29 0d 02 6c 0c ea 20  |olower(a$)..l.. |
00000600  69 25 2c 20 63 24 0d 02  76 12 e3 20 69 25 20 3d  |i%, c$..v.. i% =|
00000610  20 31 20 b8 20 a9 61 24  0d 02 80 18 20 20 20 20  | 1 . .a$....    |
00000620  63 24 20 3d 20 c1 61 24  2c 20 69 25 2c 20 31 29  |c$ = .a$, i%, 1)|
00000630  0d 02 8a 21 20 20 20 20  e7 20 63 24 20 3e 3d 20  |...!    . c$ >= |
00000640  22 41 22 20 80 20 63 24  20 3c 3d 20 22 5a 22 20  |"A" . c$ <= "Z" |
00000650  8c 0d 02 94 2a 20 20 20  20 20 20 20 20 c1 61 24  |....*        .a$|
00000660  2c 20 69 25 2c 20 31 29  20 3d 20 bd 28 97 28 63  |, i%, 1) = .(.(c|
00000670  24 29 20 2b 20 63 64 69  66 66 29 0d 02 9e 09 20  |$) + cdiff).... |
00000680  20 20 20 cd 0d 02 a8 08  3d 20 61 24 0d 02 b2 04  |   .....= a$....|
00000690  0d 02 bc 31 f4 20 65 78  69 74 20 66 72 6f 6d 20  |...1. exit from |
000006a0  68 65 72 65 2c 20 72 65  74 75 72 6e 69 6e 67 20  |here, returning |
000006b0  61 70 70 72 6f 70 72 69  61 74 65 20 69 6e 66 6f  |appropriate info|
000006c0  2e 0d 02 c6 05 f4 0d 02  d0 11 dd f2 65 78 69 74  |............exit|
000006d0  28 6e 25 2c 61 24 29 0d  02 da 25 ff 28 22 73 65  |(n%,a$)...%.("se|
000006e0  74 20 4e 65 77 73 42 61  73 65 24 52 65 74 75 72  |t NewsBase$Retur|
000006f0  6e 43 6f 64 65 20 22 2b  c3 6e 25 29 0d 02 e4 24  |nCode "+.n%)...$|
00000700  ff 28 22 73 65 74 20 4e  65 77 73 42 61 73 65 24  |.("set NewsBase$|
00000710  52 65 74 75 72 6e 49 6e  66 6f 20 22 2b 61 24 29  |ReturnInfo "+a$)|
00000720  0d 02 ee 05 e0 0d 02 f8  05 e1 0d ff              |............|
0000072c