file size check and error in file

March 17, 2009 at 17:45:45
Specs: Windows 2003
Hi

I'm using a script to check whether a file size is zero or not. If it is zero some commands need to be run and it is not zero then some others need to run.

find "Unable" test.log 2> HSSnull1
for /F %%A in ("HSSnull1") do If %%~zA equ 0 (
echo "%DTSTMP% -----Import of Online Users is sucessful-----" >> %SCRIPTLOG%
echo "%DTSTMP% -------------- End of Importing Online Users --------------" >> %SCRIPTLOG%
)
else (
echo "%DTSTMP% >>>>> ERROR: Provisioning of Online Users failed!" >> %SCRIPTLOG%
GOTO exit_process
)

But i'm getting all the lines as output, i.e. the script is not checking for the else condition.

the file size is 0KB and i'm getting this line also in the log ERROR: Provisioning of Online Users failed!"

Can sombody please help me with this.


See More: file size check and error in file

Report •


#1
March 17, 2009 at 19:49:35
)
else (

This should be one line
) else (


Report •

#2
March 17, 2009 at 23:00:01
Thanks a lot it worked!!!!!!!!!!!!!

Report •

#3
March 18, 2009 at 06:06:51
R2 strikes again.

;)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions

#4
March 18, 2009 at 09:19:50
Hi R2

One more issue here I'm searching for a string in a file

find "Unable" test.log 2> HSSnull1
for /F %%A in ("HSSnull1") do If %%~zA equ 0

and will execute some commands when it is there else will execute different set of commands.

But the issue is i was piping the output to HSSnull1 file then even though Unable is not there in test.log HSSnull1 file is created and has this content

---------- TEST.LOG

so i'm getting wrong results.

Can you please help me with this one?


Report •

#5
March 18, 2009 at 13:50:29
"find "Unable" test.log 2> HSSnull1"

I don't know why you're using that.

Nor do I know how the file name gets into that file.

I''ll stay tuned.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#6
March 18, 2009 at 22:00:08
I'm going to echo Mechanix2Go here. The only time FIND sends anything to stderr is on error. HSSnull1 should always be zero bytes, unless it can't find test.log.

You might be better off with something like this:

FIND "Unable" test.log > NUL
IF NOT ERRORLEVEL 1 @ECHO Found 'Unable' in 'test.log'


Report •

#7
March 18, 2009 at 22:23:51
I'm checking for Unable because the file will be created by a Hyperion process and if it is not able to do something, there will be a word Unable in the file.

So i want to abort the process.


Report •

#8
March 20, 2009 at 06:45:45
I tried with findstr and it is working now.

Thanks a lot for all your help.


Report •


Ask Question