Parsing AIX /etc/security/passwd file

(imported topic written by SystemAdmin)

I have a file /etc/security/passwd file that I have been parsing but it doesn’t work for the last user listed in the file. Can anyone point me to the error of my ways?

DETAIL:

Q: concatenation “|” of lines of file “passwd”

A: root:|%09password = junk|%09lastupdate = 1350336859||user1:|%09password = morejunk|%09lastupdate = 1356041428||user2:|%09password = evenmorejunk|%09lastupdate = 1339625785||user3:|%09password = junk|%09lastupdate = 1354819887

T: 463

Q: (if ((preceding text of firsts “:” of (following text of first “user1:” of (concatenation “|” of lines of file “passwd”) as string)) contains regex "password

] *=[

*morejunk") then (false) else (true))

A: False

T: 419

Q: (if ((preceding text of firsts “:” of (following text of first “user2:” of (concatenation “|” of lines of file “passwd”) as string)) contains regex "password

] *=[

*morejunk") then (false) else (true))

A: True

T: 543

Q: (if ((preceding text of firsts “:” of (following text of first “user3:” of (concatenation “|” of lines of file “passwd”) as string)) contains regex "password

] *=[

*morejunk") then (false) else (true))

E: Singular expression refers to nonexistent object.

T: 580

(imported comment written by SystemAdmin)

looks like things got messed up in cut and paste so I added the qna sessions in a txt file

(imported comment written by SystemAdmin)

Based on the relevance it won’t work. Look at it this way:

user3:|%09password = junk|%09lastupdate = 1354819887

First you are asking for: (following text of first “user3:”

That would be:

%09password = junk

%09lastupdate = 1354819887

From that response you are looking for “preceding text of firsts “:” of”

There is no “:” in this so that would explain why it doesn’t work.

Here’s one way you might consider approaching it:

//First get the text after "

:

user3:"
q: (following text of first "

:

user3:" of ((concatenation "

:

" of lines of file “c:\passwd.txt”) & "

:

"))
A: %09password = junk%09lastupdate = 1354819887

:

T: 0.394 ms

I: singular substring

//Then get the text after the first "= "

q: following text of first "= " of (following text of first “|:|user3:” of ((concatenation “|:|” of lines of file “c:\passwd.txt”) & “|:|”))

A: junk%09lastupdate = 1354819887|:|

T: 0.327 ms

I: singular substring

//finally Ask for the preceding text of the first “%09”

q: preceding text of first “%09” of (following text of first "= " of (following text of first “|:|user3:” of ((concatenation “|:|” of lines of file “c:\passwd.txt”) & “|:|”)))

A: junk

T: 0.353 ms

I: singular substring

//This will give you the password that you can then check if it equals your password.

q: preceding text of first “%09” of (following text of first "= " of (following text of first “|:|user3:” of ((concatenation “|:|” of lines of file “c:\passwd.txt”) & “|:|”))) = “junk”

A: True

T: 0.604 ms

I: singular boolean

(imported comment written by SystemAdmin)

Hello Irene,

I had an additional thought that might make this easier to work with. You can use “lines of files.” For instance:

q: lines of file “c:\passwd.txt”

A: root:%09password = junk%09lastupdate = 1350336859

A: user1:%09password = morejunk%09lastupdate = 1356041428

A: user2:%09password = evenmorejunk%09lastupdate = 1339625785

A: user3:%09password = junk%09lastupdate = 1354819887

T: 0.181 ms

I: plural file line

q: lines starting with “user3” of file “c:\passwd.txt”

A: user3:%09password = junk%09lastupdate = 1354819887

T: 0.164 ms

I: plural file line

q: line whose (it contains “user3” and it contains “junk”) of file “c:\passwd.txt”

A: user3:%09password = junk%09lastupdate = 1354819887

T: 0.167 ms

I: singular file line

q: exists line whose (it contains “user3” and it contains “junk”) of file “c:\passwd.txt”

A: True

T: 0.227 ms

I: singular boolean