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

Passing info to/from directory

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
0
0
Help I am trying to write a script for the following.

I have a directory (Telephone Equip.dir) with approximately 40 entries, sub-divided into folders, Phone Systems, Voice Mails, Answering Systems, Other Systems.

I need to access and dial into each system in the Phone Systems sub-folder. After the connection is made I have to change the password for each system with this script. The changes are no problem. However, I need to then write the OLD and NEW information to a file (that contains the following information:

Entry Name
Company Name
OLD Password
New Password

I know how to make the changes, but cannot automate the Dialing or changes. I am using the following to write all of my changes:

String fName = "New Pswd List.txt"
fopen 2 fName CREATE TEXT

if SUCCESS
fwrite 2 EntryName 20
finsblock 2 20
fwrite 2 OldPassword 10
finsblock 2 10
fputs 2 NewPassword
cTechTwoCount ++
transmit NewPassword
PAUSE 1
transmit "^M"
else
fwrite 2 sTok1 6
finsblock 2 20
fwrite 2 OldPassword 10
finsblock 2 10
fputs 2 sPswdProblem
iTechTwoCount ++
endif

Any and all help would be greatly appreciated.


 
Are you having problems with the dialing (or more likely, determining and dialing all the entries) or with the writing of the results? Instead of the fwrite/finsblock commands, you can just use fputs and it will automatically allocate the necessary space in the file.

 
Knob,

It is primarily determining the Dialing and dialing
 
You can use the dialcount command to get the number of entries in the Connection Directory, then loop throught that list and dial every entry. The code would look something like this:

dialcount DATA iEntries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName
dial DATA sName
while $DIALING
yield
endwhile
if $CARRIER
;Connection made, do commands here
else
;Connection not made, do whatever troubleshooting
endif
endfor

iCount and iEntries are string variables you would need to include in your script, sName is a string variable.

 
Knob,

What about generating a 8 character password in the following format:

LetterNumber LetterNumber LetterNumber

Example: A2F5K3Z9

I have to change about 40 passwords and they all must be different.

Any ideas?
 
About the only thing I can think of is to use the rand command to generate a random number from 1 to 26 (for each letter) or 0 through 9 (for each number), then map the result from that command to the appropriate letter (for a number value, you could just use that). For the letter, you could just have a case statement that said if the number is a 1, the letter is an A, and so forth. I'm not sure how truly random the random number generator command is, but it's probably the best solution in ASPECT.

 
Knob,

this is what I have so far. However I am having Problems puting together the 8 charicters of the password.

proc main
integer Number, lNumber ; Random number.
integer Seed, lseed ; Seed for better randomization.
string Letter

rand Seed ; Get a random integer.
rand Number Seed ; Get random integer with seed.
Number = Number % 10 ; Convert random number to a number between 0 and 9.
usermsg "The number is %d." Number
rand lSeed ; Get a random integer.
rand lNumber lSeed ; Get random integer with seed.
lNumber = lNumber % 27 ; Convert random number to a number between 0 and 9.
; usermsg "The number is %d." lNumber

switch lNumber ;Find value of numeric variable
case 0 ; and display corresponding
Letter = "A"
; usermsg "The Letter is %s." Letter
endcase
case 1
Letter = "B"
; usermsg "The Letter is %s." Letter
endcase
case 2
Letter = "C"
; usermsg "The Letter is %s." Letter
endcase
case 3
Letter = "D"
; usermsg "The Letter is %s." Letter
endcase
case 4
Letter = "E"
; usermsg "The Letter is %s." Letter
endcase
case 5
Letter = "F"
; usermsg "The Letter is %s." Letter
endcase
case 6
Letter = "G"
; usermsg "The Letter is %s." Letter
endcase
case 7
Letter = "H"
; usermsg "The Letter is %s." Letter
endcase
case 8
Letter = "I"
; usermsg "The Letter is %s." Letter
endcase
case 9
Letter = "J"
; usermsg "The Letter is %s." Letter
endcase
case 10
Letter = "K"
; usermsg "The Letter is %s." Letter
endcase
case 11
Letter = "L"
; usermsg "The Letter is %s." Letter
endcase
case 12
Letter = "M"
; usermsg "The Letter is %s." Letter
endcase
case 13
Letter = "N"
; usermsg "The Letter is %s." Letter
endcase
case 14
Letter = "O"
; usermsg "The Letter is %s." Letter
endcase
case 15
Letter = "P"
; usermsg "The Letter is %s." Letter
endcase
case 16
Letter = "Q"
; usermsg "The Letter is %s." Letter
endcase
case 17
Letter = "R"
; usermsg "The Letter is %s." Letter
endcase
case 18
Letter = "S"
; usermsg "The Letter is %s." Letter
endcase
case 19
Letter = "T"
; usermsg "The Letter is %s." Letter
endcase
case 20
Letter = "U"
; usermsg "The Letter is %s." Letter
endcase
case 21
Letter = "V"
; usermsg "The Letter is %s." Letter
endcase
case 22
Letter = "W"
; usermsg "The Letter is %s." Letter
endcase
case 23
Letter = "X"
; usermsg "The Letter is %s." Letter
endcase
case 24
Letter = "Y"
; usermsg "The Letter is %s." Letter
endcase
case 25
Letter = "Z"
; usermsg "The Letter is %s." Letter
endcase
endswitch
endproc


any Suggestions?
 
Are you getting a letter as expected when you run the script? If so, you will need to use a for loop to go from 1 to 8 to generate each of the characters in the password. You can use a second case statement on that loop variable to determine if you need to run the code to generate a random number or a random letter, something like this:

for iLoop = 1 upto 8
case 2
case 4
case 6
case 8
;Generate random number here
endcase
case 1
case 3
case 5
case 7
;Generate random letter here
endcase
endfor

Just before the endfor command, you would use the strcat command to add the letter or number generated to the password that is being built in a separate string variabel.e

 
KNOB,

Two problems on my dialing script.

1st there are 2 sub folders in the directory (Phone Mail, Other systems), I wnat to dial only the Entries under "Phone Mail".

2nd I get an error on the fetch PhoneNumber portion of the script.

Error 107: Invalid data Type encountered

Any ideas?

proc main
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sCompany ;Name of Connection Directory entry
string sAreaCode ;Area Code of Connection Directory entry
string sPhoneNumber ;Phone Number of Connection Directory entry
string sUserID ;User ID of Connection Directory entry
string sPassword ;Password of Connection Directory entry
string sMisc ;Misc of Connection Directory entry

dialcount DATA iEntries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName
fetch dialentry company sCompany ;Get Company of entry and assign to sCompany
usermsg "`"%s`"COMPANY" sCompany

fetch userid sUserID ;Get User ID of entry and assign to sUserID
usermsg "`"%s`"sUserID" sUserID

fetch password sPassword ;Get Password of entry and assign to sPassword
usermsg "`"%s`"sPassword" sPassword

fetch misc sMisc ;Get Misc of entry and assign to sMisc
usermsg "`"%s`"sMisc" sMisc

fetch dialentry areacode sAreaCode ;Get Area Code of entry and assign to sAreaCode
usermsg "`"%s`"sAreaCode" sAreaCode

fetch dialentry phonenumber sPhoneNumber ;Get Phone Number of entry and assign to sPhoneNUmber
usermsg "`"%s`"sPhoneNumber" sPhoneNumber

dial DATA sName
while $DIALING
yield
endwhile
if $CARRIER
usermsg "CONNECTED" ;Connection made, do commands here
else
usermsg "NOT - CONNECTED" ;Connection not made, do whatever troubleshooting
endif
endfor
endproc
 
OK, if you want to dial just the one group, get rid of the dialcount and for loop and use dial DATA GROUP "Phone Mail" CONNECTALL. This command will loop through all of the entries in the Phone Mail group. Drop this in place of the existing dial DATA sName command.

As for the second error, I don't have time to debug it at the moment, but try moving those after the dial process. You may need to use $DIALCONNECT to get the name of the entry that was dialed while the connection is still active, then use the set dialentry access DATA "entryname" command.

 
KNOB,

The problem is here (I have abbreviated the script fro troubleshooting):

proc main
string sUserID, sCompany, sPassword, sName, EntName
String sAreaCode, sPhoneNumber
integer Count

dial DATA GROUP "Rolm PhoneMail" sName CONNECTALL
while $DIALING
yield
endwhile
if $CARRIER
dialname DATA Count EntName ; Get name of entry.
usermsg "`"%s`"sPhoneNumber" EntName
fetch dialentry company sCompany
usermsg "`"%s`"COMPANY" sCompany
fetch userid sUserID
usermsg "`"%s`"sUserID" sUserID
fetch password sPassword
usermsg "`"%s`"sPassword" sPassword
fetch dialentry areacode sAreaCode
usermsg "`"%s`"sAreaCode" sAreaCode

;THIS FOLLOWING COMMAND FAILS ALL THE TIME
fetch dialentry phonenumber sPhoneNumber
usermsg "`"%s`"sPhoneNumber" sPhoneNumber
endif
endproc

Also the company field comes back BLANK, it should be a 7 digit number.
 
Very strange, I was seeing this on my machine when running a sample dialentry script from my site, but it appears to have cleared up after I added an area code to the entry I was testing with (only one data entry on this particular machine), but the problem did not reappear when I removed the area code. Try loading your Connection Directory, choosing File | Save, and then OK to close it, then run your script again.

 
Knob,

Nope and the Company Name is still blank also.
 
Are you setting entname anywhere in your full script?

Try running the test script below. It will run through all entries in your Connection Directory and display the phone number and company name. That way we can tell if there is something odd with the Connection Directory or if the problem is in your script somewhere.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top