Hello,

I need to get out the list of IP address of my machine to offer a choice to the user. Plateform : Debian Squeeze

[1] xxx.xxx.xxx.xxx
[2] xxx.xxx.xxx.xxx
[3] xxx.xxx.xxx.xxx
...

I have no idea how to retrieve a complete list of IP addresses to a machine.

In addition, the ${machine_addr} variable return the loopback address (127.0.0.1), so I can not use it.

I do not know if I can use a script, because this statement is required before the installation files on the server.

Thank you in advance.

This question is marked "community wiki".

asked 31 Jul '12, 09:45

mrinco's gravatar image

mrinco
0457
accept rate: 50%

Which platforms do you have to support

(31 Jul '12, 09:54) juanjo ♦♦

Sorry, It's a Debian Squeeze!

(31 Jul '12, 10:59) mrinco

You could use the below code:

    <setInstallerVariableFromScriptOutput>
      <exec>ifconfig</exec>
      <execArgs> | grep "inet add"  | grep -v 127.0.0.1 | awk '{print $2}' | awk 'BEGIN { FS=":" } { print $2 }'</execArgs>
      <name>ips</name>
    </setInstallerVariableFromScriptOutput>
     <setInstallerVariable name="ipsText" value=""/>
 <foreach variables="ip" values="${ips}">
    <actionList>
        <setInstallerVariable name="ipsText" value="${ipsText}&#xA;${ip}=${ip}"/>
    </actionList>
 </foreach>
 <addChoiceOptionsFromText>
    <name>ip</name>
    <text>${ipsText}</text>
 </addChoiceOptionsFromText>

To populate an existing parameter:

<choiceParameter>
  <name>ip</name>
  ...
  <optionList>
  </optionList>
</choiceParameter>

In any case, you could still use a packed script an unpack it manually under /tmp as explained here.

link

answered 31 Jul '12, 11:37

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Thank you so much for your help, it work great!

(01 Aug '12, 06:16) mrinco

Well 1 I would like to add another code snippet to find ip address :

proc ip:address {} { # find out localhost's IP address # courtesy David Gravereaux, Heribert Dahms set TheServer [socket -server none -myaddr [info hostname] 0] set MyIP [lindex [fconfigure $TheServer -sockname] 0] close $TheServer return $MyIP }

you can also implement Ip-details.com to find your public ip address .

link

answered 16 Dec '13, 07:19

creamuser's gravatar image

creamuser
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×73
×41
×9
×3
×1
×1

Asked: 31 Jul '12, 09:45

Seen: 3,161 times

Last updated: 16 Dec '13, 07:19