what could be this error?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alexandredneto
Posts: 39
Joined: 28 Feb 2013 13:40

what could be this error?

#1 Post by alexandredneto » 03 Feb 2014 09:16

Hi,

I edited the first lines of code, and did not work anymore.
So make available the first part of this code does not work.

Code: Select all

SET opfailed=0
SET "goto_origem="
SET "goto_ret="
setlocal enabledelayedexpansion
for /f "delims=" %%d in ('CHDIR') do set DIR=%%d&if "!DIR:~-1!" EQU "\" set DIR=!DIR:~0,-1!
for /f "tokens=1,2,3 delims=/" %%m in ("%date%") do set day=%%m&set month=%%n&set year=%%o&SET day=!day:~-2!
for /f "tokens=1,2,3 delims=:" %%h in ("%time%") do set hour=%%h&set min=%%i&set seg=%%j&SET seg=!seg:~0,2!
SET LOG=%DIR%\%COMPUTERNAME%_%year%-%month%-%day%_%hour%-%min%-%seg%.log
ECHO. > %LOG%
:iis_status
>> %LOG% ECHO ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> %LOG% ECHO 000 ROTINA: iis_status =======================================================================
for /f "delims=" %%a in ('iisreset /status') do (
   set "var=%%a"
   set "var=!var:*( =!"
   for /f "tokens=1,2 delims=): " %%b in ("!var!") do (
      set "%%b=%%c"
      >> %LOG% ECHO 000 ++ %%b %%c
      )
   )
>> %LOG% ECHO 000 ^=^=^> W3SVC: %W3SVC% ^| SMTPSVC: %SMTPSVC% ^| WinRM: %WinRM% ^| HTTPFilter: %HTTPFilter% ^| goto_origem: !goto_origem! ^| goto_ret: %goto_ret%
if defined goto_origem (
   >> %LOG% ECHO 000 ++ RETORNO: !goto_origem!
   set "goto_ret=1"
   goto !goto_origem!
   ) else (
   >> %LOG% ECHO 000 ++ ROTINA: iis_running_pergunta
   pause
   )
>> %LOG% ECHO 000 ++++++++ FALHA NA ROTINA ! ! !
pause

The result is very strange. It is created to have only 1 file. Looks like there's something in the cache, because when you run this code is created 2 files:
server.log:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
000 ROTINA: iis_status =======================================================================
000 ++
000 ++
000 ++
000 ++
000 ==> W3SVC: | SMTPSVC: | WinRM: | HTTPFilter: | goto_origem: | goto_ret:
000 ++
000 ++

server_2014-02-03_12-20-36.log:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
000 ROTINA: iis_status =======================================================================

The script is running on Windows Server 2003 Standard.

Thanks

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: what could be this error?

#2 Post by Squashman » 03 Feb 2014 09:39

alexandredneto wrote:Hi,

I edited the first lines of code, and did not work anymore.
So make available the first part of this code does not work.

Are we suppose to guess what you changed?

alexandredneto
Posts: 39
Joined: 28 Feb 2013 13:40

Re: what could be this error?

#3 Post by alexandredneto » 03 Feb 2014 10:04

I ask for help to find out if there is some logical error?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: what could be this error?

#4 Post by Squashman » 03 Feb 2014 10:29

alexandredneto wrote:I ask for help to find out if there is some logical error?

Do you think it would help if you showed us the original code that did work and what you changed it to. Seems pretty logical to me.

alexandredneto
Posts: 39
Joined: 28 Feb 2013 13:40

Re: what could be this error?

#5 Post by alexandredneto » 03 Feb 2014 10:37

Hi, guys.

Clarifications: I'm trying to add improvements!

I've isolated the lines that cause the problem.
I copied and pasted the lines (below) of the code, and when I ran did not work.

Code: Select all

@echo on
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('iisreset /status') do (
   set "var=%%a"
   set "var=!var:*( =!"
   for /f "tokens=1,2 delims=): " %%b in ("!var!") do (
      set "%%b=%%c"
      ECHO 000 ++ %%b %%c
      )
   )
pause

Result on screen:
C:\Test>setlocal enabledelayedexpansion

C:\Test>for /F "delims=" %a in ('iisreset /status') do (
set "var=%a"
set "var=!var:*( =!"
for /F "tokens=1,2 delims=): " %b in ("!var!") do (
set "%b=%c"
ECHO 000 ++ %b %c
)
)
The process tried to write to a nonexistent pipe.

This code strangely created a file: server.log.

Post Reply