Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Possible to search for a specific file, then e-mail me if found?

Discussion in 'E-mail Discussion' started by noimad1, Nov 5, 2005.

  1. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    166
    I am wondering if there is a way to do lets say a "locate" every night, and if a specific file is found, I could get an e-mail that tells me where it was found?

    I am sure there is a simple perl script that can be written to do this, but I don't know perl at all. Anyone know how I can do this?

    I know this isn't really a cpanel issue, but everyone is usually so helpfull I thought I would give it a shot...
     
  2. Zaf

    Zaf Well-Known Member

    Joined:
    Aug 22, 2005
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    166
    The following command maybe added as cron
    locate filename | mail -s "File found" email@domain.tld

    hth
     
  3. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    166
    Awesome, I will give that a try. I new that there would be an easy solution...
     
  4. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    166

    Hmmmmmm.....I guess I thought about it and would need a little more functionality. I don't want to receieve an e-mail unless that file was found.....?
     
  5. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,366
    Likes Received:
    6
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
  6. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    507
    Likes Received:
    4
    Trophy Points:
    168
    filefind

    this will do the job I think you are looking for

    Code:
    #!/bin/sh
    
    # filefind.sh - locate files then send mail to admin if files found
    
    filename=".contactemail"             # change to file you are looking for
    email="admin@domain.com"             # change to email you want to send to
    tmpfile="/tmp/filefind"
    
    # Locate the files and write to temp file
    locate $filename > $tmpfile
    RC=$?
    if [ $RC = 0 ]
    then
            mail -s "File found" $email < $tmpfile
    fi
    
    # Clean up temp file
    rm $tmpfile
    
    #
    # End
    #
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    166
    perfect, I think that will get th job done. I appreciate your help even though it was non-cpanel related....

    Regards,
    Damion
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice