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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading TEXT from a FIle 1

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
I log into a ROLM PhoneMial System and Run a Script to change Passwords for various Mailboxes. I have the PhoneMail Extensions in a Text File separated by Commas. My Problem is this:

The script works fine until ALL Extensions have been changed. When the script reaches the last entry (in the TEXT file), the Script file keeps running. The PhoneMail system is constantly scrolling through the Prompt "Subscriber Name or Extension: ".

I think that it cannot find the EOF marker. Here is the Script I have so far.

Code:
proc main

string CapPath ="C:\Program File\Procomm Plus\Download\"
string szNewPswd
;string szPswd = szNewPswd
string szSiteName
string sTok1
string sTok2
string sLine
string sEnter = "^M"
;string TableFile
sdlginput "Site Name" "Enter Site Name:" szSiteName
pause 1
sdlginput "New Password" "Enter the New DEFAULT Password:" szNewPswd 
pause 1
strcat szNewPswd sEnter
when target 0 "Extension            [" call Press_Enter
when target 1 "Name (last first)   :" call Press_Enter
when Target 2 "Class Number        :" call Press_Enter
;clear
if isfile "C:\Program Files\Procomm Plus\Download\Extns.txt"
   fopen 1 "C:\Program Files\Procomm Plus\Download\Extns.txt" READ TEXT
   capture OFF
   waitquiet 1 
   set capture path CapPath                 
   set capture file szSiteName          
   set capture overwrite ON                
   set capture query OFF                      
   capture ON
   Execute "Log-SA.wax"                   ; Logs you into the PhoneMail System
   waitfor "Function: " FOREVER             ; and gets you to the Function: Prompt
   transmit "PROFILE^M"                     ; this will bring you to the 
   waitfor "Action: "                       ; PhoneMail Modify
   transmit "MODIFY^M"                      ; prompt in the system
while not feof 1
   fgets 1 sLine
   strtok sTok1 sLine "," 1                 ;*  1st Field in File
   strtok sTok2 sLine "," 1                 ;*  2nd Field in File (2000)
   strreplace sLine " " " "
   waitfor "Subscriber Name or Extension:  "
   pause 1
   transmit sTok2
   transmit "^M"
   mspause 500
   waitfor "PhoneMail Password  : (Previous = ##########):  "
   transmit szNewPswd
   Pause 1
   waitfor "Group Name          :"
   Pause 1
   transmit ";^M"
endwhile
endif
  fclose 1
   transmit ";^M"
   waitfor "Function: " forever
   transmit "LOG^M"
   waitfor "Action: " forever
   transmit "LOG^M"
   capture OFF
   hangup
endproc

proc Press_Enter
   pause 1
   transmit "^M"
endproc


HERE IS A SAMPLE SCREEN CAPTURE. (Extensions in TEXT File are as Follows: 1234, 1235, 1236, 1237, 1238, 1239) Extension 1239 Does Not exist in the PhoneMail System.


Login:

Login: SYSADMIN
Password:
ROLM PhoneMail Version 6.3
(C) Copyright 1989-1997 Siemens Business Communication Systems.
All Rights Reserved.



ROLM PhoneMail Site Id: XXXXX94655


PhoneMail release 6.3.3.1

CPU Type of local node is GenuineIntel 80586 133MHz.
Please contact your Customer Service Representative now for service B106
PhoneMail is active with 8 Channels

Function: PROFILE
Thu Aug 29, 2002 2:09 PM

Action: MODIFY

Subscriber Name or Extension: 1234

Name (last first) : (Previous = Test Box One):
Class Number : (Previous = 30):
Extension [1] (Previous = 1234):
Extension [2]
PhoneMail Password : (Previous = ##########):
Group Name : (Previous = ):
Referral Extension : (Previous = 0):
Volume Level : (Previous = 0):
Speed level : (Previous = 0):
PhoneMail Capability: (Previous =
Accept Messages Answer Phone Do Message Alert
TRUE TRUE TRUE
Enter T or F for each field): F T F
Abbreviated Prompts?: (Previous = FALSE): ;

Subscriber Name or Extension: 1235

Name (last first) : (Previous = My Test Two):
Class Number : (Previous = 30):
Extension [1] (Previous = 1235):
Extension [2]
PhoneMail Password : (Previous = ##########):
Group Name : (Previous = ):
Referral Extension : (Previous = 0):
Volume Level : (Previous = 0):
Speed level : (Previous = 0):
PhoneMail Capability: (Previous =
Accept Messages Answer Phone Do Message Alert
TRUE TRUE TRUE
Enter T or F for each field): F T F
Abbreviated Prompts?: (Previous = FALSE): ;

Subscriber Name or Extension: 1236

Name (last first) : (Previous = My Test Three):
Class Number : (Previous = 30):
Extension [1] (Previous = 1236):
Extension [2]
PhoneMail Password : (Previous = ##########):
Group Name : (Previous = ):
Referral Extension : (Previous = 0):
Volume Level : (Previous = 0):
Speed level : (Previous = 0):
PhoneMail Capability: (Previous =
Accept Messages Answer Phone Do Message Alert
TRUE TRUE TRUE
Enter T or F for each field): F T F
Abbreviated Prompts?: (Previous = FALSE): ;

Subscriber Name or Extension: 1237

Name (last first) : (Previous = My Test Four):
Class Number : (Previous = 30):
Extension [1] (Previous = 1237):
Extension [2]
PhoneMail Password : (Previous = ##########):
Group Name : (Previous = ):
Referral Extension : (Previous = 0):
Volume Level : (Previous = 0):
Speed level : (Previous = 0):
PhoneMail Capability: (Previous =
Accept Messages Answer Phone Do Message Alert
TRUE TRUE TRUE
Enter T or F for each field): F T F
Abbreviated Prompts?: (Previous = FALSE): ;

Subscriber Name or Extension: 1238

Name (last first) : (Previous = My Test Five):
Class Number : (Previous = 30):
Extension [1] (Previous = 1238):
Extension [2]
PhoneMail Password : (Previous = ##########):
Group Name : (Previous = ):
Referral Extension : (Previous = 0):
Volume Level : (Previous = 0):
Speed level : (Previous = 0):
PhoneMail Capability: (Previous =
Accept Messages Answer Phone Do Message Alert
TRUE TRUE TRUE
Enter T or F for each field): F T F
Abbreviated Prompts?: (Previous = FALSE): ;

Subscriber Name or Extension: 1239

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension: 888888

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension: ;

Function: lo
Thu Aug 29, 2002 2:15 PM



Action: lo

Login:



Any idea what may be causing this?


 
Hello,

I use a simular Script to Transmit Phone Numbers to a Data Base. What I do is Test the String Length of Each Line Read In from the Phone List File. If the Line Read in is Less than 3 Characters ( 2 Characters Total ( CR + LF ) I exit the While Loop.

while not feof 1 ; 1 = Fopen File ID. Number
fgets 1 sLine ; 1 = Fopen # sLine = TN Number String
strlen sLine sLength
if sLength < 3
Transmit &quot;Q^M&quot; ; Send a &quot;Q&quot; to Quit FOMS INQ prompt
pause 7
exitwhile
endif
.
.
.
.
.

Let me know if this Helps.

Hank
 
Hello Again,

I failed to Mention that In the Script I use there can be a CR/LF after the Last Line String in the Numbers File. The Below Script Runs Fine and It may orMaynot help you.
Create the Following Numbers.txt File in Notepad. After the 000 Do Not enter a Enter.

Numbers.txt
111
222
333
444
555
666
777
888
999
000

Numbers.was

proc Main
string sLine
fopen 1 &quot;C:\Files\Numbers.txt&quot; Read Text
while not feof 1
fgets 1 sLine
Termwrites sLine
Termwrites &quot;`n`r&quot;
endwhile
fclose 1
endproc

Hank
 
Cool,

1 More question please. While Running this script file (See Below), I thought about a possible problem. What if One or More of the Extensions in my TEXT FILE do not appear in the System. Currently the WHEN TARGET 8 Statement sends a &quot;;^M&quot; (Exit Command). However what if that extension was removed but the Next Extension (or the 5th, or 7th, etc) is still Valid. For Example if the TEXT FILE has a list of 25 Extensions in it. And say the Third Extension Is not valid and the System responds with &quot;Cannot find this form.&quot;, however there are still 21 Extensions in the TEXT FILE. Currently the Script File EXITS.

Is there a way that if I receive this error I can process through all of the Extensions in the TEXT FILE, before EXITIING the Script File.

Here is my NEW SCRIPT FILE:

Code:
proc main
string CapPath =&quot;C:\Program File\Procomm Plus\Download\&quot;
string szNewPswd
String szSiteName
String sTok1
String sLine
integer sLength
string sEnter = &quot;^M&quot;
sdlginput &quot;Site Name&quot; &quot;Enter Site Name:&quot; szSiteName                         ; Assigns Site Name to the Variable szSiteName
pause 1
sdlginput &quot;New Password&quot; &quot;Enter the New DEFAULT Password:&quot; szNewPswd        ; Assisgns Password to szNewPswd
pause 1
strcat szNewPswd sEnter                                                     ; Adds and Enter to the szNewPswd Variable

when Target 0 &quot;Extension            [&quot; call Press_Enter
when Target 1 &quot;Name (last first)   :&quot; call Press_Enter
when Target 2 &quot;Class Number        :&quot; call Press_Enter
When Target 3 &quot;  Enter T or F for each field):  &quot; call Announce
When Target 4 &quot;Referral Extension  : &quot; call Press_Enter
When Target 5 &quot;Volume Level        : &quot; call Press_Enter
When Target 6 &quot;Speed level         : &quot; call Press_Enter
When Target 7 &quot;Abbreviated Prompts?: &quot; call Exit_MailBox
When Target 8 &quot;Cannot find this form.&quot; call Exit_MailBox

if isfile &quot;C:\Temp Data Files\Raw Data\My Site.txt&quot;                            ; Verifies that AS00.txt File does Exist.
   fopen 1 &quot;C:\Temp Data Files\Raw Data\My Site.txt&quot; READ TEXT                 ; Opens Text File AS00.txt
   capture OFF
   waitquiet 1 
   set capture path CapPath                 
   set capture file szSiteName          
   set capture overwrite ON                
   set capture query OFF                      
   capture ON
   Execute &quot;Log-SA.wax&quot;                     ; Logs you into the PhoneMail System and gets you to the Function Prompt.
   waitfor &quot;Function: &quot; FOREVER              
   transmit &quot;PROFILE^M&quot;                     ; This will bring you to the PhoneMail Modify prompt in the system
   waitfor &quot;Action: &quot; FOREVER                        
   transmit &quot;MODIFY^M&quot;                    
 while not feof 1                                                            ; 1 = Fopen File ID. Number
      fgets 1 sLine                                                           ; 1 = Fopen #  sLine = TN Number String
      strtok sTok1 sLine &quot;,&quot; 1                 ; Assigns Text in First Field (From Text File) to Variable sTok1.
      strreplace sLine &quot; &quot; &quot; &quot;
      strlen sLine sLength
      if sLength < 3
         waitfor &quot;Subscriber Name or Extension:  &quot; FOREVER
         transmit sTok1                           ; Sends the Text Value (Assigned to Variable sTok1) to the PhoneMail System.
         transmit &quot;^M&quot;
         mspause 500
         waitfor &quot;PhoneMail Password  : (Previous = ##########):  &quot; FOREVER
         transmit szNewPswd
         pause 2
         waitfor &quot;Group Name          :&quot; FOREVER
         transmit &quot;^M&quot;
      else
         exitwhile
      endif
 endwhile
endif
   fclose 1
   transmit &quot;;^M&quot;
   waitfor &quot;Function: &quot; forever
   transmit &quot;LOG^M&quot;
   waitfor &quot;Action: &quot; forever
   transmit &quot;LOG^M&quot;
   capture OFF
   hangup
endproc

proc Announce
   pause 1
   transmit &quot;F T F^M&quot;
endproc

proc Exit_MailBox
   pause 1
   transmit &quot;;^M&quot;
endproc

proc Press_Enter
   pause 1
   transmit &quot;^M&quot;
endproc
 
Hello,

There are Several Ways to Handle this Issue.

1.

Are all the Transmits the same Character Length ?
Can you Pre-Check the Line String Before sending it ?

If so, you could check the File and Delete any Invalid Transmits..
If all Transmit Lines are the Same Length you Delete them from the
Text File very Easily !

2.

Setup a Check after Transmit for a Responce, that Fails, and then simply
do a FGETS to Proceed to the Next Line in the Text File...


I won't have access to a Remote System for a Few weeks ; but I'll see what
I can do to help you out !

Hank
 
Myflight,

I am work on the same problem. Is your fixed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top