Re: OT - Batch scripting

2011-10-20 Thread Hyunkel v2.0

Nevermind I made a typo error :)

Thanks for the help :D


Hugo Ruesga 
Software Development Advisor
US  972.577.7000 x 332.3868
MX +52 (33) 3332.3868
P Please consider the environment before printing this email

The information contained in and transferred with this electronic message is 
intended only for the recipient(s) designated above, it is protected by law and 
it may contain information which is privileged and confidential. If you are not 
the intended recipient, please do not read, copy, or use it, and do not 
disclose it to others. Please notify the sender of the delivery error by 
replying to this message, and then delete it from your system. Thank you.




Date: Thu, 20 Oct 2011 10:37:24 -0400
From: kce...@hubbell.com
Subject: Re: OT - Batch scripting
To: arslist@ARSLIST.ORG

**


Try something like this…. @echo off SET maxcount=30SET increment=10SET 
countfile="c:\count.txt" REM get the current count (or start at zero if no 
current count)IF EXIST %countfile% SET /P mycounter=<%countfile%IF NOT EXIST 
%countfile% SET mycounter=0 REM increment counterSET /a 
mycounter=%mycounter%+%increment%ECHO Counter incremented to:  %mycounter%ECHO 
%mycounter%>%countfile% REM Check to see if the service needs to be restartedIF 
%mycounter%==%maxcount% GOTO RESTART GOTO END :RESTARTREM Restart the service 
hereECHO Reset Service REM Reset the countDEL /Q %countfile%  :END Ken From: 
Action Request System discussion list(ARSList) [mailto:arslist@ARSLIST.ORG] On 
Behalf Of Hyunkel v2.0
Sent: Thursday, October 20, 2011 9:25 AM
To: arslist@ARSLIST.ORG
Subject: OT - Batch scripting ** Sorry for placing this here, but i know that 
this is one of the most suitables places to find real gurus and not only for 
ARS :-);

I'm facing an error that it seems to be a logic error (from myself) or lack of 
knowledge in regards Batch scripting (I've always been Unix guy), so hope 
someone could give me some light on this.

I'm setting a monitor (not exactly, because is reactive)  process on a VM - 
Win2003 pro, for corrective purposes of Tomcat process, itself only monitors 
the established connnections within server and users, and if it finds more than 
80 established connections, will store that first violation, and wait for 
certain time to run again, if it finds more than 80 connections 3 consecutive 
times, then will stop Tomcat Server and start up again the processes.

So far I've the structure of the code but I'm finding a couple of issues that 
kept me hitting my head against the keyboard.

1.- In the monitor log, If I found more than 80 open connections at that time I 
send an ECHO 1 >>"C:\Somedirectory\Sompepath\openconnections.log", but when I 
check the log file found that it writes "1 " (the 1 and a blank space after and 
a return); is there a way to only write the file with a flat '1' with no extra 
characters?

2.- Once the file is created the program will read the information and assign 
that to a variable:

SET /P mycounter =<"C:\Somedirectory\Sompepath\openconnections.log"

I placed a ECHO output for that and I'm seeing that is getting the information 
as expected "1 ", and then

3.- I peform the validation against my flag to stop tomcat servies

IF [%mycounter%] EQU [%maxtries%] CALL rebootscript.bat

However, the validation is always true, an ECHO output for this last code line 
showed me [1 ] EQU [111]; my understanding is that I'm doing a string to string 
comparisson, but i can't figure out why DOS is assuming that 1 is the same as 
111 not the same string lenght, neither value..., I'm pretty sure I'm missing 
something here, but can't figure out what is that small piece I'm doing wrong.

Cheers.Hugo Ruesga 
Software Development Advisor
MX +52 (55) 4353.9802P Please consider the environment before printing this 
emailThe information contained in and transferred with this electronic message 
is intended only for the recipient(s) designated above, it is protected by law 
and it may contain information which is privileged and confidential. If you are 
not the intended recipient, please do not read, copy, or use it, and do not 
disclose it to others. Please notify the sender of the delivery error by 
replying to this message, and then delete it from your system. Thank you. 
_attend WWRUG11 www.wwrug.com ARSlist: "Where the Answers Are"_ 
***
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the system manager. This footnote also confirms that this
email message has been swept for the presence of computer viruses.
www.Hubbell.com - Hubbell Incorporated**


_attend WWRUG11 www.wwrug.com  ARSlist: "Where the Answers Are"_  

Re: OT - Batch scripting

2011-10-20 Thread Hyunkel v2.0

Thank you so much Ken;

But when I declare the Variable for the file I receive the  
was unexpected at this time.


Hugo Ruesga 
Software Development Advisor
US  972.577.7000 x 332.3868
MX +52 (33) 3332.3868
P Please consider the environment before printing this email

The information contained in and transferred with this electronic message is 
intended only for the recipient(s) designated above, it is protected by law and 
it may contain information which is privileged and confidential. If you are not 
the intended recipient, please do not read, copy, or use it, and do not 
disclose it to others. Please notify the sender of the delivery error by 
replying to this message, and then delete it from your system. Thank you.




Date: Thu, 20 Oct 2011 10:37:24 -0400
From: kce...@hubbell.com
Subject: Re: OT - Batch scripting
To: arslist@ARSLIST.ORG

**


Try something like this…. @echo off SET maxcount=30SET increment=10SET 
countfile="c:\count.txt" REM get the current count (or start at zero if no 
current count)IF EXIST %countfile% SET /P mycounter=<%countfile%IF NOT EXIST 
%countfile% SET mycounter=0 REM increment counterSET /a 
mycounter=%mycounter%+%increment%ECHO Counter incremented to:  %mycounter%ECHO 
%mycounter%>%countfile% REM Check to see if the service needs to be restartedIF 
%mycounter%==%maxcount% GOTO RESTART GOTO END :RESTARTREM Restart the service 
hereECHO Reset Service REM Reset the countDEL /Q %countfile%  :END Ken From: 
Action Request System discussion list(ARSList) [mailto:arslist@ARSLIST.ORG] On 
Behalf Of Hyunkel v2.0
Sent: Thursday, October 20, 2011 9:25 AM
To: arslist@ARSLIST.ORG
Subject: OT - Batch scripting ** Sorry for placing this here, but i know that 
this is one of the most suitables places to find real gurus and not only for 
ARS :-);

I'm facing an error that it seems to be a logic error (from myself) or lack of 
knowledge in regards Batch scripting (I've always been Unix guy), so hope 
someone could give me some light on this.

I'm setting a monitor (not exactly, because is reactive)  process on a VM - 
Win2003 pro, for corrective purposes of Tomcat process, itself only monitors 
the established connnections within server and users, and if it finds more than 
80 established connections, will store that first violation, and wait for 
certain time to run again, if it finds more than 80 connections 3 consecutive 
times, then will stop Tomcat Server and start up again the processes.

So far I've the structure of the code but I'm finding a couple of issues that 
kept me hitting my head against the keyboard.

1.- In the monitor log, If I found more than 80 open connections at that time I 
send an ECHO 1 >>"C:\Somedirectory\Sompepath\openconnections.log", but when I 
check the log file found that it writes "1 " (the 1 and a blank space after and 
a return); is there a way to only write the file with a flat '1' with no extra 
characters?

2.- Once the file is created the program will read the information and assign 
that to a variable:

SET /P mycounter =<"C:\Somedirectory\Sompepath\openconnections.log"

I placed a ECHO output for that and I'm seeing that is getting the information 
as expected "1 ", and then

3.- I peform the validation against my flag to stop tomcat servies

IF [%mycounter%] EQU [%maxtries%] CALL rebootscript.bat

However, the validation is always true, an ECHO output for this last code line 
showed me [1 ] EQU [111]; my understanding is that I'm doing a string to string 
comparisson, but i can't figure out why DOS is assuming that 1 is the same as 
111 not the same string lenght, neither value..., I'm pretty sure I'm missing 
something here, but can't figure out what is that small piece I'm doing wrong.

Cheers.Hugo Ruesga 
Software Development Advisor
MX +52 (55) 4353.9802P Please consider the environment before printing this 
emailThe information contained in and transferred with this electronic message 
is intended only for the recipient(s) designated above, it is protected by law 
and it may contain information which is privileged and confidential. If you are 
not the intended recipient, please do not read, copy, or use it, and do not 
disclose it to others. Please notify the sender of the delivery error by 
replying to this message, and then delete it from your system. Thank you. 
_attend WWRUG11 www.wwrug.com ARSlist: "Where the Answers Are"_ 
***
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the system manager. This footnote also confirms that this
email message has been swep

Re: OT - Batch scripting

2011-10-20 Thread Cecil, Ken
Try something like this

 

@echo off

 

SET maxcount=30

SET increment=10

SET countfile="c:\count.txt"

 

REM get the current count (or start at zero if no current count)

IF EXIST %countfile% SET /P mycounter=<%countfile%

IF NOT EXIST %countfile% SET mycounter=0

 

REM increment counter

SET /a mycounter=%mycounter%+%increment%

ECHO Counter incremented to:  %mycounter%

ECHO %mycounter%>%countfile%

 

REM Check to see if the service needs to be restarted

IF %mycounter%==%maxcount% GOTO RESTART

 

GOTO END

 

:RESTART

REM Restart the service here

ECHO Reset Service

 

REM Reset the count

DEL /Q %countfile%

 

 

:END

 

Ken

 

From: Action Request System discussion list(ARSList)
[mailto:arslist@ARSLIST.ORG] On Behalf Of Hyunkel v2.0
Sent: Thursday, October 20, 2011 9:25 AM
To: arslist@ARSLIST.ORG
Subject: OT - Batch scripting

 

** 

Sorry for placing this here, but i know that this is one of the most
suitables places to find real gurus and not only for ARS :-);

I'm facing an error that it seems to be a logic error (from myself) or
lack of knowledge in regards Batch scripting (I've always been Unix
guy), so hope someone could give me some light on this.

I'm setting a monitor (not exactly, because is reactive)  process on a
VM - Win2003 pro, for corrective purposes of Tomcat process, itself only
monitors the established connnections within server and users, and if it
finds more than 80 established connections, will store that first
violation, and wait for certain time to run again, if it finds more than
80 connections 3 consecutive times, then will stop Tomcat Server and
start up again the processes.

So far I've the structure of the code but I'm finding a couple of issues
that kept me hitting my head against the keyboard.

1.- In the monitor log, If I found more than 80 open connections at that
time I send an ECHO 1
>>"C:\Somedirectory\Sompepath\openconnections.log", but when I check the
log file found that it writes "1 " (the 1 and a blank space after and a
return); is there a way to only write the file with a flat '1' with no
extra characters?

2.- Once the file is created the program will read the information and
assign that to a variable:

SET /P mycounter =<"C:\Somedirectory\Sompepath\openconnections.log"

I placed a ECHO output for that and I'm seeing that is getting the
information as expected "1 ", and then

3.- I peform the validation against my flag to stop tomcat servies

IF [%mycounter%] EQU [%maxtries%] CALL rebootscript.bat

However, the validation is always true, an ECHO output for this last
code line showed me [1 ] EQU [111]; my understanding is that I'm doing a
string to string comparisson, but i can't figure out why DOS is assuming
that 1 is the same as 111 not the same string lenght, neither value...,
I'm pretty sure I'm missing something here, but can't figure out what is
that small piece I'm doing wrong.

Cheers.

Hugo Ruesga 
Software Development Advisor
MX +52 (55) 4353.9802

P Please consider the environment before printing this email

The information contained in and transferred with this electronic
message is intended only for the recipient(s) designated above, it is
protected by law and it may contain information which is privileged and
confidential. If you are not the intended recipient, please do not read,
copy, or use it, and do not disclose it to others. Please notify the
sender of the delivery error by replying to this message, and then
delete it from your system. Thank you.

 

_attend WWRUG11 www.wwrug.com ARSlist: "Where the Answers Are"_ 


***
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the system manager. This footnote also confirms that this
email message has been swept for the presence of computer viruses.
www.Hubbell.com - Hubbell Incorporated**


___
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug12 www.wwrug12.com ARSList: "Where the Answers Are"