0

i have a perl script that is used in updating my awstats logs of my website. The script works fine if i just paste it in cmd (Windows) but the moment i paste it in a batch file, it messes up the format of the files generated (they should be prepended with current date/time). The code is:

perl C:\PROGRA~2\AWStats\tools\awstats_buildstaticpages.pl -config=mywebsite -update -awstatsprog=C:\PROGRA~2\AWStats\wwwroot\cgi-bin\awstats.pl -dir=C:\myfolder\stats\reports -builddate=%YYYY%MM -buildpdf=C:\PROGRA~2\HTMLDOC\ghtmldoc.exe -staticlinksext=asp`

The resulting files generated is mysite.201008.asp if i paste it in cmd and execute BUT In a batch file with the same script, my resulting file is mysite.MM.asp.

Any idea why this is happening?

3 Answers 3

4

The problem is caused by %YYYY%MM.

"%" is a special symbol in batch files. You need to escape it by doubling it: %%YYYY%%MM.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried it and it works perfectly! Thank you very much atzz and all other guys who chipped in to help :)
0

It appears you have to escape the '%' characters.

2 Comments

so it should be ...-builddate=\%YYYY\%MM if i wanted it to work?
@sch-55: no, see atzz's answer
0

The command shell doing variable substitution on %YYYY% which I'm guessing is not defined in your environment, so it substitutes the empty string for that "variable".

Unfortunately, there are no opaque quotes in the Windows shell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.