Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Diskspace on Windows NT

wguessitwguessit Member Posts: 1
I need to get the size of users home directories on my server (running NT Server SP6) and post it to my company INTRANET (running Apache) on an hourly basis. I also need to get the size and available diskspace on all of my workstations and put the data to the same INTRANET on an hourly basis. Can anyone point me in the right direction on how to do this with Perl?

Thanks in advance,
Steve

Comments

  • fzapperfzapper Member Posts: 7
    : I need to get the size of users home directories on my server (running NT Server SP6) and post it to my company INTRANET (running Apache) on an hourly basis. I also need to get the size and available diskspace on all of my workstations and put the data to the same INTRANET on an hourly basis. Can anyone point me in the right direction on how to do this with Perl?
    :
    : Thanks in advance,
    : Steve
    :

    Here is one approach:

    #begin perl program
    $dirname = ".";
    system("dir $dirname /s > junk");
    open(FILE,"junk");
    @_ = ;
    close(FILE);
    $lastline = @_;
    $dir_size = @_[$lastline-2];
    $disk_remain = @_[$lastline-1];
    @fields = split(/ +/,$dir_size);
    $_ = $fields[3];
    s/,//g; #get rid of commas in the number
    print "dir and subdirs are using $_ bytes
    ";
    @fields = split(/ +/,$disk_remain);
    $_ = $fields[3];
    s/,//g; #get rid of commas in the number
    print "disk free space is $_ bytes
    ";
    #system("del junk");
    #uncomment the line above unless this script has problems
    #end perl program

    This relies on the output format of the "dir /s" command, which may vary from OS to OS (I'm running w2k) so you may need to adjust the "$dir_size =" or "$disk_size =" and/or the "split"'s. Examine the file named "junk" to determine this.

    Also you should erase the file you created named "junk" just to be clean about things.

    The workstations issue is more complicated. I assume they are all running NT? You could use the "WINAT" command to cause the relevant workstations to run similar perl script that write to a shared directory/file that lists the remaining disk space (similar to above).

    Have fun!
  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    ________ [ http://forcoder.org ] free ebooks and video tutorials about \ C++, MATLAB, Visual Basic .NET, Go, Swift, C#, Ruby, PL/SQL, Objective-C, Java, Delphi, Assembly, R, Python, PHP, Scratch, Perl, Visual Basic, JavaScript, C Ada, VBScript, Transact-SQL, Lisp, Fortran, Scheme, Prolog, SAS, Hack, Logo, Apex, FoxPro, Crystal, ML, Clojure, Bash, Alice, Julia, Awk, ABAP, Dart, D, LabVIEW, Scala, Erlang, COBOL, F#, Rust, Lua, Kotlin \ __________

Sign In or Register to comment.