Home » Archimedes archive » Acorn User » AU 1995-08.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/deluser » Compare

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

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