#67832 - 2002-07-04 05:48 PM
@ADDRESS macro from DOS
|
Anonymous
Anonymous
Unregistered
|
Hi all,
I want to use the @ADDRESS macro from DOS to populate Protocol.INI automatically and then load TCP. Unfortunately, TCPTSR needs to be loaded before @ADDRESS will work.
I have a script that will populate Protocol.INI, but once I have done this I need to unload TCPTSR and then reload it. Does anyone know how to do this?
I need to do this every month when we rebuild our 94 Citrix servers. I am trying to avoid typing the names in every month. We are also using Virtual Floppy discs, which do not allow persistent changes so rebooting is no good either...
Any thoughts?
Thanks, Michael.
|
|
Top
|
|
|
|
#67834 - 2002-07-05 09:53 AM
Re: @ADDRESS macro from DOS
|
Anonymous
Anonymous
Unregistered
|
Hi Jens,
I have a file called Servers.INI that stores all of the information for each server (IP Address, Subnet Mask, Default Gateway, WINS, DNS, etc). At the moment I need to type in the name of the server and then I can determine which section of the INI file to read. I would like to use @ADDRESS (ie the MAC address) so that I can determine which server I am running on.
Cheers, Michael.
|
|
Top
|
|
|
|
#67840 - 2002-07-05 04:37 PM
Re: @ADDRESS macro from DOS
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Michael.. you can get the ip address without the @ADDRESS macro. Have you tried using a utility like ipconfig or ping to recover the ip address? I don't know how you're configuring ip addresses, but I'm certain that there is information obtainable without using the @ADDRESS macro.
Brian [ 05 July 2002, 16:38: Message edited by: BrianTX ]
|
|
Top
|
|
|
|
#67841 - 2002-07-05 06:19 PM
Re: @ADDRESS macro from DOS
|
Anonymous
Anonymous
Unregistered
|
Hi All, thanks for the help. I have actually managed to find a solution. As Lonkero suggested the local hard disk is being erased every month and replaced with the production Citrix Server image, which also seems to change every month as we add more applications to the servers.
Writing a file to the floppy was also not an option as we are using the Compaq Remote Insite Board to insert a "Virtual Floppy" remotely, reboot the server and boot from the floppy image. This is fantastic technology as it means that I can reimage all four of our server farms without leaving my desk Unfortunately when you write to the virtual floppy the changes are lost when the machine is rebooted.
Anyway, I have managed to get a script running that loads the TCP/IP stack with an IP Address of 192.168.0.1, read the @ADDRESS macro, unload TCP/IP, update the IP Address to a pre-determined one from a text file, reload TCP/IP and then multicast the image to all of the servers.
UNLOADT is the exe that unloads TCP/IP from memory.
Here is the Autoexec.BAT that starts the whole process:
code:
@echo off
path=a:\net;a:\dos;A:\
COPY A:\Net\Protocol.DEF A:\Net\Protocol.INI COPY A:\Net\System.DEF A:\Net\System.INI
net initialize netbind.com umb.com tcptsr.exe tinyrfc.exe
KIX16 BOOT.KIX
unloadt.exe tcptsr.exe tinyrfc.eee
nmtsr.exe emsbfr.exe mouse keyb UK doskey
A:\IMAGES.BAT
Here is Boot.KIX:
code:
$ServerIniFile='A:\Servers.INI' $ProtocolIniFile='A:\Net\Protocol.INI' $SystemIniFile='A:\Net\System.INI'
SHELL 'COMMAND /C DEL A:\Images.BAT'
$FileName=$ServerIniFile $Section='MACAddress' $Key='@ADDRESS'
CALL 'ReadINI.KIX'
IF $Value<>'**Not Found**' $MacComputerName=$Value ELSE $MacComputerName='' ENDIF
$FoundComputerName=0
WHILE $FoundComputerName=0 CLS ? ? ' ****************************************************************' ? ' * *' ? ' * Generic Citrix Server Network Boot Disk *' ? ' * --------------------------------------- *' ? ' * *' ? ' * This boot disk will load dos network drivers in order to *' ? ' * connect to a network share and reimage the Citrix server *' ? ' * *' ? ' * All IP information is saved in *' ? ' *' $Space=62-LEN($ServerINIFile) $SpaceL=$Space/2 $SpaceR=$Space-$SpaceL WHILE $SpaceL>0 ' ' $SpaceL=$SpaceL-1 LOOP $ServerIniFile WHILE $SpaceR>0 ' ' $SpaceR=$SpaceR-1 LOOP '*' ? ' * *' ? ' ****************************************************************' ? ? ' MAC Address is: @ADDRESS' ? ? IF $MacComputerName='' ' Server Name: ' ELSE $Space=21-LEN($MacComputerName) WHILE $Space>0 ' ' $Space=$Space-1 LOOP 'Server Name [$MacComputerName]: ' ENDIF GETS $ComputerName IF $ComputerName='' AND $MacComputerName<>'' $ComputerName=$MacComputerName ENDIF IF $ComputerName<>'' IF SUBSTR($ComputerName,12,1)='X' $Island='TestLab' ELSE $Island=SUBSTR($ComputerName,3,6)+'Common' ENDIF $Section=$Island $Key='ImageServer' CALL 'ReadINI.KIX' ? IF $Value='**Not Found**' $DefImageServer='' ' Image Server: ' ELSE $DefImageServer=$Value $Space=20-LEN($DefImageServer) WHILE $Space>0 ' ' $Space=$Space-1 LOOP 'Image Server [$DefImageServer]: ' ENDIF GETS $ImageServer IF $ImageServer='' AND $DefImageServer<>'' $ImageServer=$DefImageServer ENDIF IF $ImageServer='' $ErrorMessage='You must enter the name of the image server!' GOTO 'Error' ELSE $Section=$ComputerName $Key='IPAddress' CALL 'ReadINI.KIX' IF $Value='**Not Found**' $ErrorMessage='Could not find IP Address for $ComputerName!' GOTO 'Error' ELSE $IPAddress=$Value CALL 'FixIP.KIX' $ServerIP=$IPAddress $Key='SubnetMask' CALL 'ReadINI.KIX' IF $Value='**Not Found**' $ErrorMessage='Could not find Subnet Mask for $ComputerName!' GOTO 'Error' ELSE $IPAddress=$Value CALL 'FixIP.KIX' $ServerSubnetMask=$IPAddress $Key='DefaultGateway' CALL 'ReadINI.KIX' IF $Value='**Not Found**' $ErrorMessage='Could not find Default Gateway for $ComputerName!' GOTO 'Error' ELSE $IPAddress=$Value CALL 'FixIP.KIX' $ServerDefaultGateway=$IPAddress $Section=$Island $Key='NameServer' CALL 'ReadINI.KIX' IF $Value='**Not Found**' $ErrorMessage='Could not find Name Server for $Island!' GOTO 'Error' ELSE $IPAddress=$Value CALL 'FixIP.KIX' $NameServer=$IPAddress $Key='NameServer' CALL 'ReadINI.KIX' IF $Value='**Not Found**' $ErrorMessage='Could not find Backup Name Server for $Island!' GOTO 'Error' ELSE $IPAddress=$Value CALL 'FixIP.KIX' $BackupNameServer=$IPAddress $FoundComputerName=1 ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ELSE $ErrorMessage='You must enter a name for this server!' GOTO 'Error' ENDIF GOTO 'OK' :Error COLOR r+/n ? $ErrorMessage ? COLOR n/n 'Press any key to continue (X to abort)...' ? GET $Key IF $Key='x' GOTO 'Abort' ENDIF $FoundComputerName=0 :OK LOOP
? ? ' Server Name: ' COLOR w+/n '$ComputerName' COLOR n/n ? ' IP Address: ' COLOR w+/n '$ServerIP' COLOR n/n ? ' Subnet Mask: ' COLOR w+/n '$ServerSubnetMask' COLOR n/n ? ' Default Gateway: ' COLOR w+/n '$ServerDefaultGateway' COLOR n/n ? ? ' Primary WINS: ' COLOR w+/n '$NameServer' COLOR n/n ? ' Secondary WINS: ' COLOR w+/n '$BackupNameServer' COLOR n/n ? ? ' Image Server: ' COLOR w+/n '$ImageServer' COLOR n/n ? ?
COLOR g+/n ? 'Configuring Protocol.INI..' COLOR n/n ? ' ' SHELL 'INI "$ProtocolINIFile" WRITE tcpip IPAddress0 "$ServerIP"' ' ' SHELL 'INI "$ProtocolINIFile" WRITE tcpip SubNetMask0 "$ServerSubnetMask"' ' ' SHELL 'INI "$ProtocolINIFile" WRITE tcpip DefaultGateway0 "$ServerDefaultGateway"' ' ' SHELL 'INI "$ProtocolINIFile" WRITE tcpip WINS_SERVER0 "$NameServer"' ' ' SHELL 'INI "$ProtocolINIFile" WRITE tcpip WINS_SERVER1 "$BackupNameServer"'
COLOR g+/n ? 'Configuring System.INI..' COLOR n/n ? ' ' SHELL 'INI "$SystemINIFile" WRITE network ComputerName "$ComputerName"'
SHELL 'COMMAND.COM /C ECHO @@ECHO OFF > A:\Images.Bat' SHELL 'COMMAND.COM /C ECHO NET USE Z: \\$ImageServer\Images /YES >> A:\Images.Bat' SHELL 'COMMAND.COM /C ECHO Z:\PQDI\IMAGE $ComputerName >> A:\Images.Bat'
GOTO 'Finish'
:Abort
:Finish
Here is ReadINI.KIX:
code:
; $Filename - INI file to read from ; $Section - SectionName to read from ; $Key - Keyname to read from ; returns $Value
$Value='**Not Found**'
IF OPEN(1,'$Filename')=0 $KeyLen=LEN($Key) $Line=READLINE(1) $Found=0 WHILE @ERROR=0 AND $Found=0 $FirstChar=SUBSTR($Line,1,1) IF $FirstChar<>';' IF $FirstChar='[' IF SUBSTR($Line,2,INSTR($Line,']')-2)=$Section $CorrectSection=1 ELSE $CorrectSection=0 ENDIF ELSE IF $CorrectSection=1 AND (SUBSTR($Line,1,$KeyLen+1)=($Key+'=')) $Value=SUBSTR($Line,INSTR($Line,'=')+1,LEN($Line)) $Found=1 ENDIF ENDIF ENDIF $Line=READLINE(1) LOOP IF CLOSE(1)<>0 'Error @ERROR closing file' ? ENDIF ELSE 'Error @ERROR while trying to open $Filename' ? ENDIF
And FixIP.KIX:
code:
; $IPAddress is IP Address to fix
WHILE INSTR($IPAddress,'.') $Pos=INSTR($IPAddress,'.') $IPAddress=SUBSTR($IPAddress,1,$Pos-1)+' '+SUBSTR($IPAddress,$Pos+1,LEN($IPAddress)) LOOP
Sigh, if only 2.33 supported UDFs
Cheers, Michael.
|
|
Top
|
|
|
|
#67842 - 2002-07-05 06:29 PM
Re: @ADDRESS macro from DOS
|
Anonymous
Anonymous
Unregistered
|
Hmmm, sorry - all of the blank lines have been stripped, making it hard to read my code - especially as there aren't many comments.
Feel free to contact me directly if anyone would like more info on how this all works.
Cheers, Michael.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|