Page 1 of 1 1
Topic Options
#67832 - 2002-07-04 05:48 PM @ADDRESS macro from DOS
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
#67833 - 2002-07-04 06:10 PM Re: @ADDRESS macro from DOS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Have the IP address stored in some kind of text file, e.g. an .INI file, then you can read the textfile under DOS.
_________________________
There are two types of vessels, submarines and targets.

Top
#67834 - 2002-07-05 09:53 AM Re: @ADDRESS macro from DOS
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
#67835 - 2002-07-05 11:06 AM Re: @ADDRESS macro from DOS
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, it's in kixtart 2.33 16bit version.

but, from
http://home.wanadoo.nl/scripting/index.htm
you can find smbios.exe
it's a good tool for hardware stuff on dos.
you don't get there info about mac (if it's not exposed by bios) but you get more specific:
quote:

Structure: Processor Information (Type 4)
Type: 4
Length: 20h
Handle: 0004h (4t)
Socket Designation: 'Socket 370'
Processor Type: 03h (Central Processor)
Processor Family: 11h (Reserved for specific Pentium versions)
Processor Manufacturer: 'GenuineIntel'
Processor ID: ..............
Processor Version: 'Pentium(R) III'
Voltage: 5V:No, 3.3V:Yes, 2.9V:No
External Clock: 100 MHz
Max Speed: 800 MHz
Current Speed: 800 MHz
Status: 41h (CPU Socket Populated, Status Enabled)
Processor Upgrade: 04h (ZIF Socket)
L1 Cache Handle: 09t
L2 Cache Handle: 10t
L3 Cache Handle: -1t (no L3 handle)

the processor id is unique so you can have 20 network cards and macs but this is const.

to get it from list I use:
smbios /g 4|find "Processor ID:"

anyway, if you want to use that address macro it really is the in dos environment.

cheers,
_________________________
!

download KiXnet

Top
#67836 - 2002-07-05 03:43 PM Re: @ADDRESS macro from DOS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I was more thinking of a text file on the local computer. Then you don't need any info at all about computer names, MAC addresses,... since the file will be unique on each computer anyway. Something like NETWORKINFO.INI:
code:
[NetworkInfo]
ComputerName=SERVER1
MAC=0011223344556677
IP=111.222.333.444
DefautlGateway=111.222.333.444.254

The info will vary for each compuetr but you can then just read the appropriate entry.
_________________________
There are two types of vessels, submarines and targets.

Top
#67837 - 2002-07-05 03:53 PM Re: @ADDRESS macro from DOS
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, I quess he's looking for something not on local disk as he is rebuilding the server.
so that's not an option, I quess.

but, don't know any reason why he couldn't use the @address-macro as it's in kixtarts dos version.

cheers,
_________________________
!

download KiXnet

Top
#67838 - 2002-07-05 03:56 PM Re: @ADDRESS macro from DOS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, I do understand, but it sounds to me like he has a boot floppy where he tries to set IP information in order to establish a TCP/IP connection to a central location. I also assume that he then uses this connection to reimage the server. Therefore, when he tries to load the network drivers, the local computer is still functional and he should be able to access the local harddrive in order to read that file.
_________________________
There are two types of vessels, submarines and targets.

Top
#67839 - 2002-07-05 04:05 PM Re: @ADDRESS macro from DOS
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah...
but also:
quote:
We are also using Virtual Floppy discs
so, he might have one imaged cd...
same type I use.
which has scripts and such stuff in it which are executed before the setup starts.

one thing I'm not sure of.
why he does not make compressed image of the installed server and use that instead of re-installing.
one reason could be that he applies updates to that image and that's why consistent image is not possible.
_________________________
!

download KiXnet

Top
#67840 - 2002-07-05 04:37 PM Re: @ADDRESS macro from DOS
BrianTX Offline
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
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 [Smile] 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 [Wink]

Cheers,
Michael.

Top
#67842 - 2002-07-05 06:29 PM Re: @ADDRESS macro from DOS
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. [Big Grin]

Feel free to contact me directly if anyone would like more info on how this all works.

Cheers,
Michael.

Top
#67843 - 2002-07-07 12:36 AM Re: @ADDRESS macro from DOS
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
michael, you are a star!

nice and ...

ooh what a code.

you have shown that there are still innovative ppl out there...
well, actually in here since you are a member too [Big Grin]

cheers,
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.05 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org