Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incrementing Input String 1

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
Help, I am trying to setup a script for a Siemens 9006 switch to automatically download traffic files.
These Files have a suffix of the Day of the study (i.e. BELINI.01, is the BELINI file for the 1st of January). I have a script file that I wrote below. The first round goes ok, however when I need to increment the suffix (01) by one is where I encounter problems. since this needs to be a 2 digit number between 01 and 31. Any number below 10 causes problems.

In addition the script file does not stop at the required point.


string sNumberDays, sStartDate, sStartDay
string sBelini = "export saved -f BELINI."
string sBiText = "export saved -f BI_01."
string sMdText = "export saved -f MD."
string sTgacc = "export saved -f TGACC."
string sEnter = "^M"
integer i, iNumberDays, iStartDay
proc main
sdlginput "Study Duration in Days" "Enter the Number of Days" sNumberDays
sdlginput "Start Date" "Enter the Start Date of the Study:" sStartDate
sdlginput "Day Started" "Enter Number of Day the Study STARTED:" sStartDay
i = 0
while 1
transmit "^M"
waitfor "LtCmd" FOREVER
transmit "list saved^M"
waitfor "LtCmd" FOREVER
for i = i upto iNumberDays ;INCREMENTS the (DAY) Date of the Study
strcat sBelini sStartDay
strcat sBiText sStartDay
strcat sMdText sStartDay
strcat sTgacc sStartDay
strcat sBelini sEnter
strcat sBiText sEnter
strcat sMdText sEnter
strcat sTgacc sEnter
transmit sBelini
waitfor "LtCmd" FOREVER
transmit sBiText
waitfor "LtCmd" FOREVER
transmit sMdText
waitfor "LtCmd" FOREVER
transmit sTgacc
waitfor "LtCmd" FOREVER
atoi sStartDay iStartDay
iStartDay++
itoa iStartDay sStartDay
endfor
endwhile
endproc


The Files I am currently trying to download are:
BELINI.05, BELINI.06, BELINI.07
BI_01.05, BI_01.06, BI_01.07
MD.05, MD.06, MD.07
TGACC.05, TGACC.06, TGACC.07

The command to download is as follows (for the BELINI.05 file):

export saved -f BELINI.05


Any and all assistance will be greatly appreciated.
 
What I would recommed doing is converting sStartDay to an integer variable after the user has entered it rather than only doing that later on in the script. To get around the leading zero problem, you would use this line to redefine the value in sStartDay based on the value in iStartDay created using atoi (as you do later in the script):

strfmt sStartDay "%02d" iStartDay

What this command does is create a two-digit string based on the value of iStartDay, and will include a leading zero if iStartDay is less than 10, due to the %02d format specifier.


aspect@aspectscripting.com
 
Knob,

Per your suggestion I added the Line you mentioned and per the USERMSG lines I added it seems to counting up now. HOWEVER, the STRINGS

sBelini = "export saved -f BELINI."
sBiText = "export saved -f BI_01."
sMdText = "export saved -f MD."
sTgacc = "export saved -f TGACC."

are now being transmitted as Blanks or NUlls on the 2nd loop when I enter 5 as Start Date/Day. see below:
The USERMSG at the end of the FOR command Shows "06"
just before it loops. However it seems the script is erasing the orginal Text info.

What is being sent is an EMPTY line with an Enter.
What should be going is: "export saved -f BELINI.06"

LtCmd: list saved

Listing (SAVED)

BELINI.01 BELINI.03 BELINI.05 BELINI.07 BELINI.09 BELINI.11
BELINI.02 BELINI.04 BELINI.06 BELINI.08 BELINI.10
BI_01.01 BI_01.03 BI_01.05 BI_01.07 BI_01.09 BI_01.11
BI_01.02 BI_01.04 BI_01.06 BI_01.08 BI_01.10
MD.01 MD.02 MD.03 MD.04 MD.05 MD.06 MD.07 MD.08 MD.09 MD.10 MD.11
TGACC.01 TGACC.03 TGACC.05 TGACC.07 TGACC.09 TGACC.11
TGACC.02 TGACC.04 TGACC.06 TGACC.08 TGACC.10

LtCmd:

List Traffic/ Data Retrieval -- available commands:

list diag
list [saved]
export raw [-f <filename>]
export [saved] [-f <filename>]
status
reset [raw -save <# of days>]
exit

Please enter command, followed by <return>

LtCmd:


Here is the Updated Script I have so far.


string sNumberDays, sStartDate, sStartDay
string sBelini = &quot;export saved -f BELINI.&quot;
string sBiText = &quot;export saved -f BI_01.&quot;
string sMdText = &quot;export saved -f MD.&quot;
string sTgacc = &quot;export saved -f TGACC.&quot;
string sEnter = &quot;^M&quot;
integer i, iNumberDays, iStartDay
proc main
sdlginput &quot;Study Duration in Days&quot; &quot;Enter the Number of Days&quot; sNumberDays
; sdlginput &quot;Start Date&quot; &quot;Enter the Start Date of the Study:&quot; sStartDate
sdlginput &quot;Day Started&quot; &quot;Enter Number of Day the Study STARTED:&quot; sStartDay
i = 0
atoi sStartDay iStartDay
strfmt sStartDay &quot;%02d&quot; iStartDay
while 1
transmit &quot;^M&quot;
waitfor &quot;LtCmd&quot; FOREVER
transmit &quot;list saved^M&quot;
waitfor &quot;LtCmd&quot; FOREVER
for i = i upto iNumberDays ;INCREMENTS the (DAY) Date of the Study
strcat sBelini sStartDay
strcat sBiText sStartDay
strcat sMdText sStartDay
strcat sTgacc sStartDay
strcat sBelini sEnter
strcat sBiText sEnter
strcat sMdText sEnter
strcat sTgacc sEnter
usermsg &quot;StartDay: `&quot;%s`&quot; &quot; sStartDay
usermsg &quot;BELINI File Name: `&quot;%s`&quot; &quot; sBelini
usermsg &quot;BI File Name: `&quot;%s`&quot; &quot; sBiText
usermsg &quot;MD File Name: `&quot;%s`&quot; &quot; sMdText
usermsg &quot;Tgacc File Name: `&quot;%s`&quot; &quot; sTgacc
transmit sBelini
waitfor &quot;LtCmd&quot; FOREVER
transmit sBiText
waitfor &quot;LtCmd&quot; FOREVER
transmit sMdText
waitfor &quot;LtCmd&quot; FOREVER
transmit sTgacc
waitfor &quot;LtCmd&quot; FOREVER
iStartDay++
itoa iStartDay sStartDay
atoi sStartDay iStartDay
strfmt sStartDay &quot;%02d&quot; iStartDay
usermsg &quot;New StartDay: `&quot;%s`&quot; &quot; sStartDay
PAUSE 5
endfor
endwhile
endproc


As always your help is GREATLY Appreciated.
 
KNOB,

I finally got this script to work. Thanks for all of the Help.

If anyone needs a Script to manually download (LtDr) traffic for a Siemens 9006 Switch, here you go.


string sNumberDays, cNumberDays, sStartDay
string sBelini = &quot;export saved -f BELINI.&quot;
string sBiText = &quot;export saved -f BI_01.&quot;
string sMdText = &quot;export saved -f MD.&quot;
string sTgacc = &quot;export saved -f TGACC.&quot;
string sEnter = &quot;^M&quot;
integer i, iNumberDays, iStartDay
proc main
sdlginput &quot;Study Duration in Days&quot; &quot;Enter the Number of Days&quot; sNumberDays
sdlginput &quot;Day Started&quot; &quot;Enter Number of Day the Study STARTED:&quot; sStartDay
i = 1
atoi sStartDay iStartDay
strfmt sStartDay &quot;%02d&quot; iStartDay
strcat sBelini sStartDay
strcat sBiText sStartDay
strcat sMdText sStartDay
strcat sTgacc sStartDay
strcat sBelini sEnter
strcat sBiText sEnter
strcat sMdText sEnter
strcat sTgacc sEnter
atoi sNumberDays iNumberDays
transmit &quot;^M&quot;
waitfor &quot;LtCmd&quot; FOREVER
transmit &quot;list saved^M&quot;
waitfor &quot;LtCmd&quot; FOREVER
for i = i upto iNumberDays ;INCREMENTS the (DAY) Date of the Study
itoa i cNumberDays
itoa iNumberDays sNumberDays
; usermsg &quot;Number of i: `&quot;%s`&quot; &quot; cNumberDays
; usermsg &quot;Number of Days: `&quot;%s`&quot; &quot; sNumberDays
itoa iNumberDays sNumberDays
strfmt sStartDay &quot;%02d&quot; iStartDay
atoi sStartDay iStartDay
strupdt sBelini sStartDay 23 2 ; Update sBelini String with new Date
strupdt sBiText sStartDay 22 2 ; Update sBiText String with new Date
strupdt sMdText sStartDay 19 2 ; Update sMdText String with new Date
strupdt sTgacc sStartDay 22 2 ; Update sTgacc String with new Date
transmit sBelini
waitfor &quot;LtCmd&quot; FOREVER
transmit sBiText
waitfor &quot;LtCmd&quot; FOREVER
transmit sMdText
waitfor &quot;LtCmd&quot; FOREVER
transmit sTgacc
waitfor &quot;LtCmd&quot; FOREVER
; usermsg &quot;BELINI File Name: `&quot;%s`&quot; &quot; sBelini
; usermsg &quot;BI File Name: `&quot;%s`&quot; &quot; sBiText
; usermsg &quot;MD File Name: `&quot;%s`&quot; &quot; sMdText
; usermsg &quot;Tgacc File Name: `&quot;%s`&quot; &quot; sTgacc
iStartDay++
itoa iStartDay sStartDay
atoi sStartDay iStartDay
strfmt sStartDay &quot;%02d&quot; iStartDay
endfor
transmit &quot;exit^M&quot;
waitfor &quot;^[[0;40;37m^[[1m^[[20;78H&quot;
transmit &quot;^[[V&quot;
waitfor &quot;ATZ&quot;
transmit &quot;^M^M^M&quot;
waitfor &quot;login: &quot;
transmit &quot;^M&quot;
endproc





KNOB, thanks again for all the help.
 
I see that you are downloading these files from the hicom switch. I have successfully downloaded these files as well and I am now trying to read them. Do you know how these files can be opened and interpreted? What steps should be followed in order to open one of these files and acquire the traffic statistics that are contained in the file?

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top