Hi

I have written a script to list the file size of a file for windows based 
servers. I wrote this as I couldnt seem to get the WMI Filesize scripts to work 
and im not sure why. But here we go


Code:

#!/usr/bin/perl
#  
# Lists the size of a particular file. At present only
# one file per command
#
# FILEURL = filepath and filename eg c:\windows\file.exe
# FILENAME = filename eg file.exe (this must be the same as the filename above 
in the FILEURL)
# 
# eg. filesize.pl server domain/user password 
"drive:\\folder\\filename.extension" filename.extension
#
# Get Args
       $numargs = $#ARGV;

if ($numargs != 4) {
   print "filesize.pl HOSTNAME USERNAME PASSWORD \"FILEURL\" FILENAME ...\n";
   print "FILENAME must be all lowercase";
   print "\n";
   exit 0;
   }

else {
        $hostname = @ARGV[0];
        $username = @ARGV[1];
        $password = @ARGV[2];
        $fileurl = @ARGV[3];
        $filename = @ARGV[4];
     }

# Change the Username to work with winexe
  $username =~ s!//!\/!g;    

# Run Winexe and get the results

  $output =`\/usr/local/zenoss/common/bin/winexe -U '$username'%'$password' 
//$hostname 'cmd /c dir /L /-C "$fileurl"' | grep -i "$filename" | sed 
's/'"$filename"'/ /g' | sed 's/^.\\{17\\}//g' | sed 's/^[ \\t]*//\;s/[ 
\\t]*\$//'`;
  $result = "OK|$filename=$output";
  print "$result";
  exit 0;





Hope this helps someone

Thanks




-------------------- m2f --------------------

Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=26542#26542

-------------------- m2f --------------------



_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to