Results 1 to 5 of 5

Thread: Scripting

  1. #1
    Join Date
    Apr 2004
    Posts
    4

    Post Scripting

    Hi,

    I don't know if I'm in the right forum but I found this site from the net. I'm looking for somebody who could help me with simple shell scripting. I want to create a script that will look at certain/multiple directories and then tell me if those dirs have contents/files in them and alert me if they contain files. I want to put this in a simple shell script, the directories are fixed ones.

    Appreciate your help!!!

    Thanks!!!

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can use VBSCript (assuming you are in Windows environment).

    There are many sample scripts here

    http://www.microsoft.com/technet/tre...er/default.asp

  3. #3
    Join Date
    Mar 2003
    Posts
    468
    if you are in a unix env i would do something like this. don't know the type of alert you are looking for. you will have to put that call in the code.

    #!/bin/sh
    echo "/bin:*.exe" > directory.lst
    echo "/bin:*.dmp" >> directory.lst
    echo "/usr/lib:*.a" >> directory.lst
    for DIRECTORY in `cat directory.lst`
    do
    DIR=`echo $DIRECTORY | awk -F: '{print $1}'`
    PATTERN=`echo $DIRECTORY | awk -F: '{print $2}'`
    FILECOUNT=`ls -l ${DIR}/${PATTERN} | wc -l`
    echo "${FILECOUNT} Files in Directory:Pattern ${DIRECTORY}"
    test $FILECOUNT -gt 0
    if [ $? = 0 ]
    then
    echo "Alert"
    fi
    done

  4. #4
    Join Date
    Apr 2004
    Posts
    4
    I'm using Unix so I guess I can try this. Thanks guys for the help!!!

  5. #5
    Join Date
    Apr 2004
    Posts
    4
    Hi jkoopman,

    I hope you could help me with another scripting problem of mine. I need to monitor certain directories and check whether the files in those directories are updated. By updated I mean that they were placed there within the last five minutes. If no file/s is in the directories within the last five minutes, I wanted to be alerted of it. How do I create a shell script for this?

    Hope you can help me with this, I really am not familiar with shell scripting and having such a hard time trying to figure out how to do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •