Command to upload 404 files to multiple domains.

prettydumb

Active Member
Aug 25, 2007
35
0
56
When I set up my domains, several thousand of them, I did not include 404 error pages or robots.txt files. My logs show I should also be uploading favicons as well.

I now know I should have set this up as I was entering the domain name into the system via root public_html.

Is there a command you might share to have these files entered, without having to log into each separate account?

Someone please throw a dummy a bone.
 

prettydumb

Active Member
Aug 25, 2007
35
0
56
Can you tell me more about your modified script?

Can you give me instructions on how to implement?
 

verdon

Well-Known Member
Nov 1, 2003
934
16
168
Northern Ontario, Canada
cPanel Access Level
Root Administrator
To use these, you need to login via ssh with a terminal/shell session. If you're not comfortable working in terminal a little bit, then you should get someone else to do it.

I have a folder in my root dir with a few personal scripts like this one in it.

So, I login via ssh and then...
cd /root/scripts/

then...
sh fix404errors.pl


To deal with missing favicons, I use the following script, in a file called 'fixfaviconerrors.pl' NOTE: For this to work, you must have a generic favicon file at /root/cpanel3-skel/public_html/favicon.ico which will get copied to any user public_html dir that doesn't already have one. You can easily modify this example for a basic robots.txt file too, or whatever your want.
Code:
#!/usr/bin/perl


print "Starting Scan...\n";

while(@USERS=getpwent()){
        if (-d "$USERS[7]/public_html") {
                if (-f "$USERS[7]/public_html/favicon.ico") {
                        print "$USERS[0] favicon.ico exists\n";
                } else {
                        print "$USERS[0] copying favicon.ico...";
                        use File::Copy;
                        copy("/root/cpanel3-skel/public_html/favicon.ico", "$USERS[7]/public_html/favicon.ico") or die "File cannot be copied.";
                        chmod(0644, "$USERS[7]/public_html/favicon.ico") or die "Unable to chmod file: $!";
                        chown($USERS[2],$USERS[3],"$USERS[7]/public_html/favicon.ico") or die "Unable to chown file: $!";
                        print "done\n";
                }
        }
}


print "Scan Complete!\n";
Good luck,
verdon