The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help finding a string within a file

Discussion in 'General Discussion' started by s3kk3y, Mar 26, 2003.

  1. s3kk3y

    s3kk3y Well-Known Member

    Joined:
    Oct 12, 2002
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    6
    In my error_log, I have almost 1000 entries of this line:

    [Wed Mar 26 04:16:49 2003] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!

    I know why I am getting that and i want to correct whoevers .htaccess file that is causing those messages.

    What cmd can i use to search all .htaccess files within /home/ searching for the string "401" and "http"?
     
  2. taivu

    taivu Well-Known Member

    Joined:
    Nov 22, 2001
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    find . -name ".htaccess" -type f -print | xargs grep -e 'Error.*401.*http' /dev/null

    should do what you want, assuming you are in /home directory. The answer to your question would be:

    find . -name ".htaccess" -type f -print | xargs grep -e '.*401.*http' /dev/null
     
  3. s3kk3y

    s3kk3y Well-Known Member

    Joined:
    Oct 12, 2002
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    6
    Thanks,

    It first didnt find any matches, so i made it look for just "401" and it came up with 1 user.

    The weird thing is, he had his .htaccess set as:

    ErrorDocument 401 /index.htm

    Does it have to be the full path? I changed it anyways, but i want to make sure that i set it correctly. I changed it to:

    ErrorDocument 401 /home/username/public_html/index.htm
     
  4. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    To read the error msg. another way, it would sound like, "Since a complete URL is not being used for the re-direction, the Error directive will be ignored."

    Simply use a full URL and there should not be a problem.
     
  5. taivu

    taivu Well-Known Member

    Joined:
    Nov 22, 2001
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    That is how it should be. Have you checked your httpd.conf? Make sure you have no ErrorDocument directives with full URL in there.

    grep -e 'Error.*401.*http' /usr/local/apache/conf/httpd.conf
     
  6. s3kk3y

    s3kk3y Well-Known Member

    Joined:
    Oct 12, 2002
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    6
    i double checked my httpd.conf and the only line with 401 is:

    ErrorDocument 401 /401.shtml

    My httpd has thousands of directive error lines now. =(
     
  7. taivu

    taivu Well-Known Member

    Joined:
    Nov 22, 2001
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    Well, if there's an entry in error_log, there must be a matching request entry in your access_log or (most likely) in one of the domlogs. Grab the latest error date and time and convert it to the format used in the access logs. I'll use the one from your first post in this thread in my example.

    Error_log entry:
    [Wed Mar 26 04:16:49 2003] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!

    Access log date and time would be: "26/Mar/2003:04:16:49"

    find /usr/local/apache/domlogs -type f -print0 | xargs -0 fgrep -l "26/Mar/2003:04:16:49"

    should give you a list of files that contain that timestamp. If no luck, run the same for /usr/local/apache/logs.
     
Loading...

Share This Page