55 users online (1 members and 54 guests)  


  Results 1 to 5 of 5

Related

  1. Replies: 0
  2. Replies: 1
  1. #1
    DuMaurier69's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2002
    Posts
    18

    Theres a problem i cant solve

    opendir(ETC,"/home");
    while ($name = readdir(ETC)){
    if ($user eq $name){

    print("<font color=red><b><BR><BR>$user");
    print("</b><BR><BR>");$disk=exec"du -s /home/$user");
    print("</b><BR><BR>");

    }
    }
    print ("</BODY></HTML>");
    closedir(ETC);
    My unix is telling me there is a problem with this but i cant find it if some one can tell me where it is my program will be finished i also want the program to print just $disk=exec"du -s" but it also comes up with the directory name too how can i remove it

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    I think Enigma has a lot of experience with Perl, Enigma, any thoughts?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426
    What is the error message/problem that you're getting when you try to run this?

  4. #4
    bresticals's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2004
    Location
    england.
    Posts
    7
    regex is your answer, something like...

    use du -Sh (h will show the value in a more readable format and S shows a summary.

    regex just before you print the value to screen will strip out the directory:
    $user =~ s/$user//g;

    and you may need at the start of the loop:
    next if $user eq '.';

  5. #5
    bresticals's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2004
    Location
    england.
    Posts
    7
    oh iand rather than doing:

    if ( $name eq $user ) {

    do:

    if ( $user =~ /$name/ ) {

    cos it might not be exact.



Tags for this Thread