Reading a line at a time from a file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bjg

    Reading a line at a time from a file

    Hey,

    Just wondering what the best way to do this is?

    What i specifically want to do is check if a user exists on a unix machine.
    The best way i was told was to read a line at a time of /etc/passwd and
    check if the username is in that line.

    Cheers


  • RG

    #2
    Re: Reading a line at a time from a file


    "bjg" <bjg_at_interno de.on.net> wrote in message
    news:3f70508d$1 @duster.adelaid e.on.net...[color=blue]
    > Hey,
    >
    > Just wondering what the best way to do this is?
    >
    > What i specifically want to do is check if a user exists on a unix[/color]
    machine.[color=blue]
    > The best way i was told was to read a line at a time of /etc/passwd and
    > check if the username is in that line.
    >
    > Cheers
    >
    >[/color]


    see file();
    RG


    Comment

    • David Gillen

      #3
      Re: Reading a line at a time from a file

      An noise sounding like bjg said:[color=blue]
      > Hey,
      >
      > Just wondering what the best way to do this is?
      >
      > What i specifically want to do is check if a user exists on a unix machine.
      > The best way i was told was to read a line at a time of /etc/passwd and
      > check if the username is in that line.
      >[/color]
      system("grep <username> /etc/password") and process the result. Probably a
      whole hella lot quicker on system with a large number of users and reading in
      and having php parse and search the whole file.

      Dave
      --

      I'm a dead man, and buggered to boot!

      Comment

      Working...