Linux admin script w/ Perl - how to?


Recommended Posts

Hell All,

This is a class assignment that I have to do. I have no knowledge of Perl and I'm new to Linux, but I want to do it on my own. Please don't give me the answer or script as yet. What I'd like to get is the Linux command first, and lil bit of help , then I'll post my code and then someone can tell me if I'm doing ok.

Please include my 1st line of code for Perl. I know it starts with #!

==================================================

As a system administrator, you are required to provide a daily report on the storage usage for your users. All your users are restricted to the /home/user_name directory structure.

You need to parse through the passwd file for a list of regular user names (i.e. those with userid number >= 500) and then run the command du with the correct options to obtain a summary of each users disk usage for that directory.

When you have run the command - you should write the results to a file called:

yyyymmddhhmm.du (note the date is needed in the above file name)

Note - you will need to do this on a Linux machine and also - in order to get the information on all the home directories - you will need to run your script as root. BUT - you can write most of this on a windows machine to begin with - get a copy of a passwd file to parse through. You can create a dummy directory structure to walk through and issue a dummy du command until you are in a position to run the thing on a Linux box.

You are strongly advised to comment your code well and to make backups along the way.

================================================

Thanks

Link to comment
Share on other sites

Hell All,

This is a class assignment that I have to do. I have no knowledge of Perl and I'm new to Linux, but I want to do it on my own. Please don't give me the answer or script as yet. What I'd like to get is the Linux command first, and lil bit of help , then I'll post my code and then someone can tell me if I'm doing ok.

Please include my 1st line of code for Perl. I know it starts with #!

==================================================

As a system administrator, you are required to provide a daily report on the storage usage for your users. All your users are restricted to the /home/user_name directory structure.

You need to parse through the passwd file for a list of regular user names (i.e. those with userid number >= 500) and then run the command du with the correct options to obtain a summary of each users disk usage for that directory.

When you have run the command - you should write the results to a file called:

yyyymmddhhmm.du (note the date is needed in the above file name)

Note - you will need to do this on a Linux machine and also - in order to get the information on all the home directories - you will need to run your script as root. BUT - you can write most of this on a windows machine to begin with - get a copy of a passwd file to parse through. You can create a dummy directory structure to walk through and issue a dummy du command until you are in a position to run the thing on a Linux box.

You are strongly advised to comment your code well and to make backups along the way.

================================================

Thanks

Just curious... Do you have to use Perl? I think a basic dump could be done with a normal bash script... maybe... If your assignment requires perl, I can't help, as I don't know it... :(

Link to comment
Share on other sites

The assignment has to be done in Perl yes, but I don't mind also trying to learn it the way that you know it. The more I know, the better. (Y)

Go right ahead and give me a sample and I'll try your way also.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.