Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How to ask for help

by Limbic~Region (Chancellor)
on Nov 24, 2003 at 17:02 UTC ( [id://309593]=note: print w/replies, xml ) Need Help??


in reply to Standardized Template

tux242,
You have been working on this problem at least since 30 October. A lot of monks have spent a great deal of time both in replying to your posts and in the CB. I am more than willing to help you and even avoid modules if you will take the time to explain in clear and concise requirements what your ultimate goal is.

Here is an example of what I mean, which may or may not be what you are after.

EXAMPLE
I have been given the daunting task of ensuring uniformity of the user accounts and passwords across multiple *nix systems. I have already extracted a copy of all the /etc/passwd files from each of the servers and have used the following syntax for identifying them - passwd.hostname

I am trying to avoid using modules due to a number of reasons. The two biggest reasons is that my employer has made it a requirement and I need to be able to explain the code line by line. I do not mind "borrowing" ideas from modules, but ultimately the code needs to be my own.

So the type information I need to get out of my program is as follows:

  • Account x does not exist on hostname1 or hostname2
  • Account y's UID on hostname1 is #, but is # on hostname2
  • Account j's password on hostname1 is not the same as all the other machines.

    So basically, I need to compare every field against every other field as well as make provisions for the possibility the field won't exist at all on certain servers. My first hurdle is that the encrypted password is not stored in /etc/passwd but in /etc/shadow. I am using shadow.hostname syntax for that.

    Here is what I have come up with so far:

    #!/usr/bin/perl -w use strict; my @hosts = qw(zeus mercury athena); my (@p_files, @s_files); my %data; for my $host ( @hosts ) { push @p_files , 'passwd.' . $host; push @s_files , 'shadow.' . $host; } # Process /etc/passwd files FILE: for my $file ( @p_files ) { if ( ! open (PASSWD, $file) ) { warn "Unable to open $file : $!"; next FILE; } LINE: while ( <PASSWD> ) { my @fields = split /:/; if ( @fields != 7 ) { warn "$_ in file $file is corrupt"; next LINE; } $data{$fields[0]}->{$file} = \@fields; } } # Process /etc/shadow files FILE: for my $file ( @s_files ) { if ( ! open (SHADOW, $file) ) { warn "Unable to open $file : $!"; next FILE; } LINE: while ( <SHADOW> ) { # Not sure what to do here # but I know I need to modify # $data{account}->{$file}[1] } } # Need code help here to do all the comparisons I need
    Additionally, any help or insight would be appreciated. I am rather new to Perl so I understand this might not be the best approach. If you do choose to suggest an alternative approach, keep in mind my requirements I stated above
    END EXAMPLE

    I can guarantee tux242 that if you word take the time to pose a question like this you will be much more likely to get answers that you are seeking.

    Cheers - L~R

  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: note [id://309593]
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others scrutinizing the Monastery: (3)
    As of 2024-04-26 07:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found