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!

Reseting the User-Id and Password in the Directory

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
Help,

I am trying to change the values in one of my directories. I usally change passwords and would like to automatically update procomm. I wrote a script, however it does not seem to work properly (of course or i wouldn't be asking questions here).

The script prompts you for the SiteName Login and Password, then attempts to change the settings in the Test directory.

I removed all of the waitfor and transmit lines to see if it works...and no go.

Code:
proc main
string szNewPswd
string szSiteName
string szLogin
string szCompany
; Assigns Site Name to the Variable szSiteName
sdlginput "Site Name " "Enter Site Name:" szSiteName                         
   pause 1
; Assigns Company Name to the Variable szCompany
sdlginput "Company Name " "Enter Company Name:" szCompany                         
   pause 1
; Assigns Login Name to the Variable szLogin
sdlginput "Login to be CHANGED" "Enter Login Name:" szLogin                         
   pause 1
; Assigns Password to szNewPswd
sdlginput "New Password" "Enter the New DEFAULT Password:" szNewPswd        
   pause 1
dialload "test.DIR"
      if not nullstr szSiteName        ; Make sure entry isn't empty.
         if dialfind DATA SzSiteName SzSiteName
            usermsg "The entry is called `"%s`"." SzSiteName
            set dialentry access DATA szSiteName
            szLogin = $MISC
            szNewPswd = $PASSWORD
            szCompany = $COMPANY
            set userid szLogin
            set password szNewPswd
            set dialentry company szCompany
            dialsave
         endif
      endif
enproc

ANY SUGGESTIONS????
 
If you comment out the line:

szLogin = $MISC
szNewPswd = $PASSWORD
szCompany = $COMPANY

then the script will work as expected. What is happening is you are reading the current values from the Connection Directory (in my case, these strings were null since it was a new entry), and are thus writing back the current values of the entry instead of what your entered in the dialogs.
aspect@aspectscripting.com
 
Knob,

it still does not change the Login, Password and company name??
 
I'm able to just comment out the three mentioned lines in the original script you posted and it still works fine for me. Is the entry you are trying to modify in the loaded Connection Directory? Are you sure the Connection Directory is being loaded successfully by the dialload command?
aspect@aspectscripting.com
 
Knob,

Man I must have been asleep. I forgot that I hade created a Temporary Directory called TEST.DIR, where all the changes were bieng made.

Question: I have to open a Directory (TEST.DIR) dial the system & change the password. I would like to change the information in the directory (Which this Script does).

However, the Directory will have More than ONE entry. I would Like to perfor the same operation on ALL entries.

Next, I would like to Export the changes to a LOG or TEXT file. So If ProComm crashes there is a Record of the Changes. Since Windows 95 is such a stable platform (NOT).
I can pretty much figure out most of the Commands.

FOPEN 1 Pswd "C:\Change.txt" CREATE
fwrite 1


Except,
How do I ensure the changes to the File are Written?
Change the Line the text file is writing to (i.e., New Line for each DIALENTRY?

The Text/Log file would look something like this:

SiteName Company Login OldPswd NewPswd OldMisc NewMisc

Your assistance as always is greatly appreciated.

 
To get the format of the line correct, you could use the strfmt command. Something like:

strfmt sOutput "%s $s %s %s %s %s %s" SiteName Company Login OldPswd NewPswd OldMisc NewMisc

woudl create a string called sOutput that contains all of the values of the specified strings. You would then use fputs 1 sOutput to the file.

Unfortunately, I don't think there is a way to ensure that the data is written to the file if Procomm crashes. If Procomm crashes, then the script will most likely crash immediately as well. To work around this possibility, you could fclose the file after each write, then fopen it again before the next fputs/fwrite command aspect@aspectscripting.com
 
THANKS,

If a session (paasword change) is completed for the First 5 Sites, and ProComm crashes, would the file maintain the first 5 changes and only lose the 6th??

If this is possible then at least if the FCLOSE command doens't work I would have 5 of the 6.

Thanks Again
 
Final Question:

How can I change the script file to Step through each of the entries in the TEST.dir?? For example if the Test Directory has 3 Sub-Folders (Test1, Test2, Other), and I want to change the Passwords for every site in the Directory I CHOOSE??

Code:
proc main
string szSiteName,szCompany,szLogin,sOutput
string szOldPswd,szOldMisc
string szNewPswd,szNewMisc
szOldPswd = $PASSWORD
szOldMisc = $MISC
sdlginput "Site Name " "Enter Site Name:" szSiteName                         
   pause 1
sdlginput "Company Name " "Enter Company Name:" szCompany                         
   pause 1
sdlginput "Login to be CHANGED" "Enter Login Name:" szLogin                         
   pause 1
sdlginput "New Password" "Enter the New DEFAULT Password:" szNewPswd        
   pause 1
dialload "test.DIR"
      if not nullstr szSiteName        ; Make sure entry isn't empty.
         if dialfind DATA SzSiteName SzSiteName
            fopen 1 "C:\Change.txt" CREATE 
            usermsg "The entry is called `"%s`"." SzSiteName
            set dialentry access DATA szSiteName
            set userid szLogin
            set password szNewPswd
            set dialentry company szCompany
            strfmt sOutput "%s   $s   %s   %s   %s    %s   %s" szSiteName,szCompany,szLogin,szOldPswd,szNewPswd,szOldMisc,szNewMisc
	    fputs 1 sOutput 
            dialsave
         endif
      endif
endproc
 
Regarding Procomm crashing while the script is modifying the change file, I can't say if the information from previous file writes would be saved in the file or not. The worst case scenario would be a zero-byte file. I would think that the data entered during previous writes and followed by an fclose would be OK, although further testing would be needed to ensure this.

As for changing the password for all entries in a file, this script shows how to iterate through all data entries in a Connection Directory, and assigns a user ID, password, and company to all entries. It won't quite drop into your script as is, but should give you some ideas on how to re-architect your script:

proc main
integer iNumEntries, iCount
string szSiteName
string szLogin, szNewPswd, szCompany

szLogin = "Login"
szNewPswd = "Password"
szCompany = "Company"

dialcount DATA iNumEntries ; Get number of DATA entries.
for iCount = 0 upto (iNumEntries - 1) ; dialname zero-based.
dialname DATA iCount szSiteName
set dialentry access DATA szSiteName
set userid szLogin
set password szNewPswd
set dialentry company szCompany
dialsave
endfor
endproc aspect@aspectscripting.com
 
Knob,

I was able to incorporate the script you provided me with mine and it work great.

Is there anyway to set the Password to automatically generate a password. I am looking to change these password however each on needs to be different. The should be 8 charicters in length and alphabetical.

 
You can use the rand command to create a random integer, but there's not an out-of-the-box way to create a random string. You should be able to create something, perhaps using the rand command to create a random integer between 22 and 125 decimal that you then convert to the corresponding ASCII character using the strfmt command (strfmt strvar "%c" intvar would place the ASCII value corresponding to intvar in the strvar variable). You could then perform this operation seven more times, ending with 8 random characters that you would concatenate together to create a (hopefully) pseudo-random string. aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top