wilsonkjit
asked on
Batch file help. %%i was unexpected at this time (also Pause is ignored)
I have the following batch file running fine at an other site sending me latest NTbackup Logs.
When trying to run it on this server (Server 2003 Standard Server SP1) it fails. Pls see below
@echo off
::Batch file - send out latest backuplog*.log file in current folder
rem Gathering all files in current folder with mask specified...
rem /A-D... no directories (or folders)
rem /OD... sort by date (oldest first)
rem /B... no heading information or summary rem /TW... last Writen file
dir backuplog*.log /A-D /OD /TW /B >tmp.txt
rem parse tmp.txt file to get last line...
rem last line is latest .log file...
rem so attach.txt will contain .log file we want...
for /F "tokens=*" %i in (tmp.txt) do echo %i >attach.txt <-- this is where it fails with a %%i was unexpected at this time.
febootimail -smtp SERVER -subject "NTBackup Logs" -FROM backup@client.com -TO backups@us.biz -ATTACH -USEFILE attach.txt
Also when I stick a pause line in the batch file during troubleshooting it ignores the pause.
I usually run the batch file from "C:\Documents and Settings\Administrator\Loc al Settings\Application Data\Microsoft\Windows NT\NTBackup\data" folder
Any help appreciated
Best
Wilson
When trying to run it on this server (Server 2003 Standard Server SP1) it fails. Pls see below
@echo off
::Batch file - send out latest backuplog*.log file in current folder
rem Gathering all files in current folder with mask specified...
rem /A-D... no directories (or folders)
rem /OD... sort by date (oldest first)
rem /B... no heading information or summary rem /TW... last Writen file
dir backuplog*.log /A-D /OD /TW /B >tmp.txt
rem parse tmp.txt file to get last line...
rem last line is latest .log file...
rem so attach.txt will contain .log file we want...
for /F "tokens=*" %i in (tmp.txt) do echo %i >attach.txt <-- this is where it fails with a %%i was unexpected at this time.
febootimail -smtp SERVER -subject "NTBackup Logs" -FROM backup@client.com -TO backups@us.biz -ATTACH -USEFILE attach.txt
Also when I stick a pause line in the batch file during troubleshooting it ignores the pause.
I usually run the batch file from "C:\Documents and Settings\Administrator\Loc
Any help appreciated
Best
Wilson
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
D'oh -
Sorry last post was dumb, I just answered my own question.. take out the "" surrounding %%i
Case closed its working
Thanks sooo much
Best
Wilson
Sorry last post was dumb, I just answered my own question.. take out the "" surrounding %%i
Case closed its working
Thanks sooo much
Best
Wilson
ASKER
Very Nearly.....
it creates the attach.txt (contents of file "backuplog07.log")
the only problem now is for the next febootimail line to work I need the backuplog07.log to not be enclosed by "" in attach.txt.
Any ideas?
Cheers for your help..
Wilson