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

Compare StarterPak/!Newsbase/Transports/taylor/moduser with StarterPak/!Newsbase/Transports/taylor/deluser

File: Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/moduser
Compared with: Archimedes archive » Acorn User » AU 1995-08.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/deluser
Similarity: 59% of bytes duplicated

52 of 93 lines (61.5%) are identical in the two listings. Duplicated Different

Line numbers are ignored when comparing lines, so that renumbered programs still match.

StarterPak/!Newsbase/Transports/taylor/moduser StarterPak/!Newsbase/Transports/taylor/deluser
10REM >moduser 10REM >deluser
20REM modify a user to the /etc/passwd file, whereever it is. 20REM delete a user from the /etc/passwd file, whereever it is.
30REM 30REM
40REM Author: Gunnar ZREPORTtl 40REM Author: Gunnar ZREPORTtl
50REM Date: 10-Nov-1994 50REM Date: 18-Sep-1994
60REM Last modified: 15-Dec-1994 60REM Last modified: 06-Nov-1994
70 70
80ONERROR REPORT:PRINT" at line ";ERL:END 80ONERROR REPORT:PRINT" at line ";ERL:END
90 90
100LIBRARY "<NewsBase$TaylorDir>.ScriptLib" 100LIBRARY "<NewsBase$TaylorDir>.ScriptLib"
110 110
120REM default value for group 120REM default value for group
130GRP% = 1 130GRP% = 1
140 140
150REM get command line parameters 150REM get command line parameters
160PROCentry 160PROCentry
170IF (argc = 3) OR (argc = 5) THEN 170IF (argc = 3) THEN
180 FOR i%=1 TO argc - 1 180 IF argv$(1) = "-u" THEN
190 CASE argv$(i%) OF 190 N$ = argv$(2)
200 WHEN "-u": N$ = argv$(i% + 1): i% += 1 200 ELSE
210 WHEN "-g": GRP% = VAL(argv$(i% + 1)): i% += 1 210 PROCexit(1, "Invalid Parameters")
220 OTHERWISE PROCexit(1, "Invalid Parameter") 220 ENDIF
230 ENDCASE 230ELSE
240 NEXT i% 240 PROCexit(1, "Invalid Parameters")
250ENDIF 250ENDIF
260 260
270REM remove spaces from username. 270REM remove spaces from username.
280user$ = FNstripspaces(N$) 280user$ = FNstripspaces(N$)
290user$ = FNtolower(user$) + ":" 290user$ = FNtolower(user$) + ":"
300len% = LEN(user$)
310 300
320IF FNgetenv("Wimp$ScrapDir") = "" THEN 310IF FNgetenv("Wimp$ScrapDir") = "" THEN
330 PROCexit(0, "ScrapDir must have been seen") 320 PROCexit(0, "ScrapDir must have been seen")
340ENDIF 330ENDIF
350etcpasswd$ = FNupath("/etc/passwd") 340etcpasswd$ = FNupath("/etc/passwd")
360etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd") 350etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd")
360cdiff = ASC"a" - ASC"A"
370 370
380REM we copy from /etc/passwd to the temp. file until we find 380REM we copy the passwd file to a scrapfile line by line,
390REM the specified user. Then we just alter his group number, 390REM omitting the line that has our user.
400REM and write the new entry out to the temp. file.
410if% = OPENIN(etcpasswd$) 400if% = OPENIN(etcpasswd$)
420IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd") 410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd")
430of% = OPENOUT(etcbpasswd$) 420of% = OPENOUT(etcbpasswd$)
440IF of% = 0 THEN PROCexit(1, "could not open " + etcbpasswd$) 430IF of% = 0 THEN PROCexit(1, "could not open <Wimp$ScrapDir>.passwd")
450i% = 0 440l% = LEN(user$)
460j% = 0
470REPEAT 450REPEAT
480 c$ = GET$#if% 460 c$ = GET$#if%
490 IF LEFT$(c$, len%) = user$ THEN 470 IF user$ <> FNtolower(LEFT$(c$, l%)) THEN BPUT #of%,c$
500 i% = INSTR(c$, ":") 480UNTIL c$ = ""
510 i% = INSTR(c$, ":", i% + 1)
520 REM extract strings before and after group number
530 i% = INSTR(c$, ":", i% + 1)
540 j% = INSTR(c$, ":", i% + 1)
550 o$=LEFT$(c$, i%) + STR$(GRP%) + MID$(c$, j%)
560 BPUT #of%,o$
570 ELSE
580 BPUT #of%,c$
590 ENDIF
600UNTIL (c$="")
610CLOSE #of% 490CLOSE #of%
620CLOSE #if% 500CLOSE #if%
510OSCLI("settype " +etcbpasswd$ + " FFF")
630 520
640IF i% > 0 THEN 530REM now copy our new file over the old one then exit and tell
650 REM now copy our new file over the old one then exit and tell 540REM NewsBase that all went fine.
660 REM NewsBase that all went fine. 550OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
670 OSCLI("settype " +etcbpasswd$ + " FFF") 560PROCexit(0, "user added")
680 OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
690 PROCexit(0, "user " + user$ + " modified")
700ELSE
710 REM otherwise complain and die.
720 PROCexit(1, "user " + user$ + " not found")
730ENDIF
740END 570END
750 580
760REM convert all characters in a string to lowercase. 590REM convert all characters in a string to lowercase.
770REM 600REM
780DEF FNtolower(a$) 610DEF FNtolower(a$)
790LOCAL i%, c$ 620LOCAL i%, c$
800FOR i% = 1 TO LENa$ 630FOR i% = 1 TO LENa$
810 c$ = MID$(a$, i%, 1) 640 c$ = MID$(a$, i%, 1)
820 IF c$ >= "A" AND c$ <= "Z" THEN 650 IF c$ >= "A" AND c$ <= "Z" THEN
830 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff) 660 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff)
840 ENDIF 670 ENDIF
850= a$ 680= a$
860 690
870REM exit from here, returning appropriate info. 700REM exit from here, returning appropriate info.
880REM 710REM
890DEFPROCexit(n%,a$) 720DEFPROCexit(n%,a$)
900OSCLI("set NewsBase$ReturnCode "+STR$n%) 730OSCLI("set NewsBase$ReturnCode "+STR$n%)
910OSCLI("set NewsBase$ReturnInfo "+a$) 740OSCLI("set NewsBase$ReturnInfo "+a$)
920END 750END
930ENDPROC 760ENDPROC