Check user usage in a folder

Reply
Super User
Posts: 17,774

Check user usage in a folder

Does anyone have a program they use to scan a library (AIX UNIX Server) and determine how much space each user is using?

Respected Advisor
Posts: 3,124

Re: Check user usage in a folder

That is what I want to know on a Windows server hosting SAS. I haven't been granted remote access to server's desktop, only have SAS admin right. So I can see certain folders and files using MC, but I want to know how much available space left without involving Windows team every time.

Haikuo

Super Contributor
Posts: 644

Re: Check user usage in a folder

Reeza

If you have read access to the user directories you can write a Unix script to list recursively file names and sizes to a text file, then use SAS to launch the script via the X command and read in the data in a SAS data step.  It's a bit tedious because you have to separate out header records for each directory (and possibly retain the directory name).  I don't have an example.  You can also use Unix df and du (disk free and disk used) to see whether there is a problem looming.

There are SAS functions which can be used to interrogate the file system, which might be an alternate route.

Haikuo

The same approach will work on Windows, provided that you have at least read access to the folders.  I cannot see any way to monitor if you do not have such access.  I do not know whether there is a Windows equivalent to df, which might be all you need if it is available

Richard

Super User
Posts: 17,774

Re: Check user usage in a folder

I was hoping for something using dictionary tables and SAS alone.

From those I can see file size though I know it's not 100% correct, but I dont' know how to get the user/owner. If I right click on the library and check the properties I can see the owner, but looking for a way to do that via programming.

Super Contributor
Posts: 644

Re: Check user usage in a folder

Reeza

Since you asked, you can create a list of file names and the directories they are in using the dictionary tables.  This list can then be processed using SAS external file functions iteratively.  For each file, use the following

  • the FILENAME() function to assign a file name
  • the FOPEN() function to open the file for read
  • the FINFO() function with 2nd parameter 2 to get the owner (for UNIX - check Windows doc)
  • the FINFO() function with 2nd parameter 5 to get the size in bytes (for UNIX - check Windows doc)
  • the FCLOSE() function to close the file
  • the FILENAME() function to deassign the file name

Do until done

Richard

Ask a Question
Discussion stats
  • 4 replies
  • 665 views
  • 0 likes
  • 3 in conversation