Re: open transport database scripting
Re: open transport database scripting
- Subject: Re: open transport database scripting
- From: David Blache <email@hidden>
- Date: Wed, 03 Jan 2001 18:56:00 -0600
on 1/3/2001 6:01 PM, Nathan Ardoin wrote:
>
Alright I have been beating my head all day on this one, let me give you a
>
rundown first, moving machines from one subnet to another, so the router info
>
and ip address has to change (easy part) what I can't get my script to do is
>
copy the last 3 digits of the old IP address and put them onto the end of the
>
new ip address, so lets say here is the old: 192.168.1.27, I want the new one
>
to be: 192.168.20.27, is there a way to do this? or am I just wishing? (I am
>
trying to eliminate actually opening the tcp/ip control panel on 200 machines,
>
if at all possible.
Hi Nathan,
Here's how I would do it:
-- assumes that the "Default" configuration is being used
set newSubnet to ".20.27"
log newSubnet
-- get old IP
tell application "Network Setup Scripting"
open database
set oldIP to the IP address of configuration "Default"
--set oldIP to the IP address of (TCPIP v4 configurations)
close database
end tell
set oldIP to oldIP as text
log oldIP
-- manipulate textual IP to the new IP
set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set newIP to (text items 1 thru 2 of (oldIP as text)) as text
set newIP to newIP & newSubnet
set AppleScript's text item delimiters to saveDelims
-- change IP address
tell application "Network Setup Scripting"
open database
set the transaction_ID to begin transaction
set the IP address of configuration "Default" to "1.1.1.1"
set IP address of (TCPIP v4 configurations) to newIP
end transaction
close database
end tell
log newIP
-David
--
___________________________________________________________________
David Blache email@hidden
Metrowerks Corporation
http://www.metrowerks.com