Plesk's Awstats show Select Period in wrong order
13 comments
Comment from: Pete [Visitor]

Comment from: davidnewcomb [Member]

Yes - install ed!
http://www.gnu.org/software/ed/


For some reason when trying to execute the script I am getting the following error:
./plesk-awstats-nav-fixer.sh: line 60: syntax error: unexpected end of file
Any ideas?
I suspect this is related somehow in EOF marks on the file itself, as the Notepad++ seems to color the rest of the file from the first EOF line to blue.
I have tried Notepad++ as well as pico when editing, but same error occurs when trying to execute the script…
Comment from: davidnewcomb [Member]

The file doesn’t contain 60 lines so there must be a problem with the characters at the end of the file.
Try cut and pasting it into something like notepad. Yeh - I know, the side effect of all its faults is that it does strip away anything that is not ASCII. Then save as plain text, and you should be fine.

Comment from: davidnewcomb [Member]

The trouble is that you have cut and pasted the script from this page straight into your terminal. When you did so the editor added some indentation. In doing so it would have indented the EOF marker from the end of the “ed” script. With no marker the file terminates at the end of the file with the error.
To correct the problem move the EOF marker so that it is the only text on the line and it starts at the beginning of the line.

Comment from: davidnewcomb [Member]

Maybe I can get another blog article about using inline pipes in shell scripts.
I have uploaded the file to here: http://www.bigsoft.co.uk/projects/sample-code/plesk-awstats-nav-fixer.sh
You will see that the following “ed” line finishes with EOF:
ed nav_nooptions.html << EOF
and all the lines to the corresponding EOF
marker are how they would appear in the file that would have been piped in.


Comment from: davidnewcomb [Member]

Formatting the dates would be handled by the awstats generation file. The program merely sorts the existing entries into order. You’ll have to read all about awstats yourself. Besides if Plesk is messing up the ordering already and you try to sort Jan, Feb, … into alphabetical order they will be even more messed up!
As far as I know the month thing is not fixed in Plesk either but my solution still works as is.
Comment from: Jennifer Arsenault [Visitor]

I know this is an old article, but I thought I could help someone else. Apparently, this is still an issue on Plesk 11.
I’m moving to a new server, and I’m new to Plesk. I just figured out how to migrate years of Awstats data files and was irritated by the random menu order. It’s especially an issue if there are more than a couple of months. A Google search brought me here. And your script is just what I needed.
However, I too would like to have text months rather than numbers, so I set out to tweak your script. Although I do have a programming background, this is my first attempt at shell programming. There’s probably a better way to do this, but here is what I came up with.
Add the following line near the top where the other variables are set. Use full months instead of abbreviated ones if you prefer. MONTHS=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
Add the following 4 lines at line 48.
for MONTH in 1 2 3 4 5 6 7 8 9 10 11 12
do
sed -i “s/-printf '%.2d' $MONTH
</ ${MONTHS[MONTH-1]}</g” nav_options.html
done
The above changes only the display months and not the values so it doesn’t affect function at all. I haven’t tested the original or edited script via cron yet, but it works from the command line.
Hope it helps someone else.
Form is loading...
Hi there, I’ve tried to implement this script but get the following error…
./plesk-awstats-nav-fixer.sh: line 49: ed: command not found
Can you recommend any fixes?
Many thanks in advance