Reading a line at a time from a file

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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


    bjg Guest

  2. Similar Questions and Discussions

    1. Reading Last Line in a Txt File
      Hi, I'm trying to read the last line in a file using "ASFileRead" function. Im having trouble specifying the last parameter which counts the...
    2. Reading a file from a URL at design-time
      Im' building a custom menu control based on a XML file. I've added the following property: private string _xmlSourceUrl; public string...
    3. install HTML::Template - Problem reading cache file / Bad file number
      i get the following error when i try to install HTML::Template to my local space, ie, not as root: +---------------------------- % perl -MCPAN...
    4. Reading tab delimited File & sort everything according item 5 of every line
      let say that the file contains these items (every item is seperated with a tab) one title state name code1 number two title2 state2 ...
    5. Reading a scalar line by line
      Hi, does anyone know how I would do this? something like: while ($string) print _$ } Google searches did not turn up anything.
  3. #2

    Default Re: Reading a line at a time from a file


    "bjg" <bjg_at_internode.on.net> wrote in message
    news:3f70508d$1@duster.adelaide.on.net...
    > 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
    >
    >

    see file();
    RG


    RG Guest

  4. #3

    Default Re: Reading a line at a time from a file

    An noise sounding like bjg said:
    > 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.
    >
    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!

    David Gillen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139