accesschk script to include datestamp

Discussion in 'Scripting' started by Altria, Nov 13, 2008.

  1. Altria

    Altria Guest

    Hello All,
    I would like to automate a daily report of accesschk againsts a file server
    but would like to include a datestamp, for example;

    accesschk -rws "group" "folder target" > %datestamp%.txt

    I would like afterwards to run a diff command (what is the equivalent of
    this in windows?) against the files and see if any access permissions have
    changed

    Any help would be greatly appreciated!

    Thanks,
    Altria
     
    Altria, Nov 13, 2008
    #1
    1. Advertisements

  2. Altria

    Altria Guest

    Tom thanks for your fast reply!
    That is exactly what I needed.

    For the second question would it be more complicated to have the file
    compare utility do a condition process whereby if changes between files are
    found it would send an email?
    Or would I need something much more involeved to get that kind of
    automation?

    Thanks again,
    Altria
    Try something like this to get a datestamp ...

    for %%a in (%date%) do set datestamp=%%a
    set datestamp=%datestamp:/=%
    accesschk -rws "group" "folder target" > %datestamp%.txt

    It creates a date stamp in a form of ddmmyyyy in the US or mm-dd-yyyy
    elsewere. A more 'sortable' date stamp requires significantly more
    code. Handling dates, in general, is locale dependent, which can
    complicate explaining how to get one in batch. It's a bit easier in
    WinScript, but that seems to be off topic.

    The other question about comparing file contents can be done with the
    FC (file compare) utility. For example (in XP), ...

    fc file1.txt file2.txt > nul
    if not errorlevel 1 (
    echo Files are identical
    ) else (
    echo Files are different
    )

    Tom Lavedas
    ***********
    http://there.is.no.more/tglbatch/
     
    Altria, Nov 13, 2008
    #2
    1. Advertisements

  3. Building on Tom's code:
    fc file1.txt file2.txt > nul
    if not errorlevel 1 (
    echo Files are identical
    ) else (
    blat /.. /..
    )

    blat.exe is a Command Line mailer that you can download from a number of
    sites. You could also use a VB Script mailer but since you're running a
    batch file there seems to be little point in moving to a hybrid solution.
     
    Pegasus \(MVP\), Nov 13, 2008
    #3
  4. Altria

    Altria Guest

    Thank you Pegasus!
    Actually another question then would be do you think that the accesschk is
    the best way of capturing and automating this information. Is there a better
    way and simpler way via vbscript, perl,python etc.?

    Thanks again,
    Altria
     
    Altria, Nov 13, 2008
    #4
  5. Sorry, I know nothing about accesschk and what it does.
     
    Pegasus \(MVP\), Nov 13, 2008
    #5
  6. Altria

    Altria Guest

    Accesschk is by sysinternals (MS) and allows you to enumerate access
    permissions of a group or user to a folder or files on the system. It is
    command-line based and is similar to the GUI equivalent which accessenum

    The problem with these utilities is that they are very general. What if I
    wanted a specific user or more than one but not a group, I am unable to do
    this. That is why I was curious to know if there was a "preferred" method of
    obtaining and tracking access rights to shares?

    Thanks,
    Altria
     
    Altria, Nov 17, 2008
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.