Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently January 9th, 2025, 9:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Need a Script for displaying Local IP
PostPosted: November 2nd, 2008, 2:13 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
Hi guys/gals

I have been all over the NET for a script that displays Local IP Number . Does anyone have 1 thats works ?


I have found 1 thats supposed to do it and save data to a Txt file but it doesnt work so i threw it away . Displaying a Local IP is crucial Info and there must be 1 around LOL ...


Any Help appreciated

Al

You can tell Winters coming , i am back on the forums ;)

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 2nd, 2008, 7:26 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Depends on what you mean by "local" IP :-)
Your local IP is 127.0.0.1
Or do you mean the one you see on some websites that say, for example "your local IP is 127.87.34.33" ?
Unless you are on a fixed IP address this number will change whenever you reboot your router and your ISP gives you a new one.

Paul


Top
 Profile  
 
 Post subject:
PostPosted: November 2nd, 2008, 8:38 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
paul wrote:
Depends on what you mean by "local" IP :-)
Your local IP is 127.0.0.1
Or do you mean the one you see on some websites that say, for example "your local IP is 127.87.34.33" ?
Unless you are on a fixed IP address this number will change whenever you reboot your router and your ISP gives you a new one.

Paul


The local machine iP ...... not the Internet 1

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 2nd, 2008, 11:54 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
local IPs should be those viable to a private network - IE home / work they differ from you IP on a public network - IE the web.

127.0.0.0 is a local IP but is normally used for loopback purposes. All you local IP addresses can be seen by entering ipconfig in the command prompt. And when I say addresses, it's because most people have more than one - the machine I'm using has 5 - so you have the additional problem of which local IP address you need.

If this Opus project is for fun, then I'd simply have the ipconfig dump to a tetx file and read the contents into Opus. If you need a less messy and more professional - look into a DLL that would return the local IP address. There seem to be snippets of c++ code out there for this but not in DLL form that my quick search turned up.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 3rd, 2008, 12:06 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
I don't think ipconfig will give what he wants. It just gets the gateway.

Update::
Ignore this post, brainfade moment.

Paul


Last edited by Paul on November 3rd, 2008, 12:56 am, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: November 3rd, 2008, 12:09 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
how'd you figure (or what did I miss this time :-))

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 3rd, 2008, 12:16 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
I'm getting confused.
I'm not sure what Al wants now :)

Paul


Last edited by Paul on November 3rd, 2008, 12:33 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: November 3rd, 2008, 12:25 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Me too but thankfully it's late enough that I can have another glass of wine :-)

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 3rd, 2008, 12:27 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
I usually have a glass of wine at 4pm -- just three and a half hours to go!

Al, run this batch file -- it'll put the ipconfig details into a text file on your desktop. Works ok on XP and Vista.
Does the text file contain the information you want?

cheers
Paul


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 Post subject:
PostPosted: November 3rd, 2008, 1:01 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
paul wrote:
I usually have a glass of wine at 4pm -- just three and a half hours to go!

Al, run this batch file -- it'll put the ipconfig details into a text file on your desktop. Works ok on XP and Vista.
Does the text file contain the information you want?

cheers
Paul




OK i dont need to be secretive LOL what i am doing guys is making a program to help my GAMERS buddies with a simple solution to finding there IP LOL . You would be suprised how many people cant find a 747 Jet in a hay stack LOL.....

Being a beginner to scripting and code ( as mack knows already ) i did spend hours looking for script BUT wasn't 100% sure if i found the right thing . OK OK i admit it i am a 47 year old gamer LOL , but i spend hours helping peopel to find simple Network data on their comps and i really want to simplify it .

Is there away to get that data into a Variable ????

. BUT the IP is most important as many are behind routers and they get confused buy there internal and External IP when i ask them .

Knowing if there comp is in DHCP or Static would be great info as well , but hey i 'll keep looking for help OR an easy way for that as well.....i guess a more elaborate dump of the ipconfig would supply that as well?

Thanks guys for your help and i am sure amny gamers will be thankful as well ( smile )......

Al and NO i'm not to old to be a gamer ;)

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 4th, 2008, 11:31 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Al,

Basically, you just need to read the contents of the of the batch file into Opus and then extract the bits of information you want.

The following script will build the batch file, execute it and read the contents into a variable displayed in the debug command. You'd need to check each line being read for the information you want and probably pass this to a different variable. I'd suggested looking at the contains and substring commands for this process.


//Creates files
var batchObject = OpenFile(SYSTEM_TEMP_DIR+"ip.bat",true)
batchObject.WriteLine("ipconfig /all >> "+SYSTEM_TEMP_DIR+"ip.txt")
batchObject.Close()

LaunchFile(SYSTEM_TEMP_DIR+"ip.bat")

wait(1)


tmpData
var ipconfigObject = OpenFile(SYSTEM_TEMP_DIR+"ip.txt",false,true)

//This loop reads the data in from the file. It is here that you can format the bits you want.

//Try looking at the contains & substring commands on how to extract data.



while (ipconfigObject .EndOfFile() == false)
{
tmpData+= ipconfigObject .ReadLine()+"\n"
}

ipconfigObject .Close()

Debug.trace(tmpData)



//cleans up.

DeleteFile(SYSTEM_TEMP_DIR+"ip.bat")
DeleteFile(SYSTEM_TEMP_DIR+"ip.txt")

Mack.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 4th, 2008, 12:01 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
mackavi wrote:
Hi Al,

Basically, you just need to read the contents of the of the batch file into Opus and then extract the bits of information you want.

The following script will build the batch file, execute it and read the contents into a variable displayed in the debug command. You'd need to check each line being read for the information you want and probably pass this to a different variable. I'd suggested looking at the contains and substring commands for this process.


//Creates files
var batchObject = OpenFile(SYSTEM_TEMP_DIR+"ip.bat",true)
batchObject.WriteLine("ipconfig /all >> "+SYSTEM_TEMP_DIR+"ip.txt")
batchObject.Close()

LaunchFile(SYSTEM_TEMP_DIR+"ip.bat")

wait(1)


tmpData
var ipconfigObject = OpenFile(SYSTEM_TEMP_DIR+"ip.txt",false,true)

//This loop reads the data in from the file. It is here that you can format the bits you want.

//Try looking at the contains & substring commands on how to extract data.



while (ipconfigObject .EndOfFile() == false)
{
tmpData+= ipconfigObject .ReadLine()+"\n"
}

ipconfigObject .Close()

Debug.trace(tmpData)



//cleans up.

DeleteFile(SYSTEM_TEMP_DIR+"ip.bat")
DeleteFile(SYSTEM_TEMP_DIR+"ip.txt")

Mack.


Geezzzz Mack your always so through LOL......

Would displaying a line be as simple as as stating some thinng like " Display line 7 " LOL........... or do i just place the line to be read inbetween the Brackets.... tmpData+= ipconfigObject .ReadLine(7)+"\n"

I understand most of your script mack and i am enveious on how easy it seems to come to you LOL......Is there a good beginers book on basic scripting ? . Anyways i will carry on and have a look at how the script runs and will give'R a go...

Al

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 4th, 2008, 12:53 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
:-)

I'd start by

changing this bit:

while (ipconfigObject .EndOfFile() == false)
{
tmpData+= ipconfigObject .ReadLine()+"\n"
}

ipconfigObject .Close()

Debug.trace(tmpData)

to

while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
Debug.trace(tmpData+'\n')
}

ipconfigObject .Close()


THIS WILL basically read each line at a time into the variable tmpData and then show it in the debug pane. The "\n" just inserts a new line.


You cannot simply specify a line by number but you can do something similar using a counter.

_____________________________________________________
var counter = 0

while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
if (counter == 5) Debug.trace(tmpData+'\n') //IE only show line five
counter++ //same as counter = counter + 1
}

ipconfigObject .Close()

THIS WILL only show line five. BUT you could also have more ifs that do all sorts of things such as reading different lines into different variables.

Have a play and see what you can make it do.

The problem with books is that they tend to focus on JavaScript for the web. OpusScript is basically the same as JavaScript, except that you don't have all the web bits but the principle is the same. Books like the JavaScript in 24hrs and the Dummies series are great for understanding the concept of programming in Opus Script even if you cannot use the code directly.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 4th, 2008, 5:14 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
mackavi wrote:
:-)

I'd start by

changing this bit:

while (ipconfigObject .EndOfFile() == false)
{
tmpData+= ipconfigObject .ReadLine()+"\n"
}

ipconfigObject .Close()

Debug.trace(tmpData)

to

while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
Debug.trace(tmpData+'\n')
}

ipconfigObject .Close()


THIS WILL basically read each line at a time into the variable tmpData and then show it in the debug pane. The "\n" just inserts a new line.


You cannot simply specify a line by number but you can do something similar using a counter.

_____________________________________________________
var counter = 0

while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
if (counter == 5) Debug.trace(tmpData+'\n') //IE only show line five
counter++ //same as counter = counter + 1
}

ipconfigObject .Close()

THIS WILL only show line five. BUT you could also have more ifs that do all sorts of things such as reading different lines into different variables.

Have a play and see what you can make it do.

The problem with books is that they tend to focus on JavaScript for the web. OpusScript is basically the same as JavaScript, except that you don't have all the web bits but the principle is the same. Books like the JavaScript in 24hrs and the Dummies series are great for understanding the concept of programming in Opus Script even if you cannot use the code directly.

Mack


Thanks for your time Mack,

Cold weather is back on monday and i wil be back infront of the monitor by then , Wish me Luck LOL....

Al

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 4th, 2008, 6:22 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
To extract the lines containing the words "IP Address", use the "String.contains(string,test)" function.
I use this method in my weather example to extract relevant lines of info.

change this

while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
Debug.trace(tmpData+'\n');
}


to this


while (ipconfigObject .EndOfFile() == false)
{
tmpData = ipconfigObject .ReadLine()+"\n"
if(String.contains(tmpData,"IP Address")){
Debug.trace(tmpData+'\n');
}
}

And only lines containing "IP Address" will be shown.


Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 72 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group