0

I have a file which contains following content. I want to be able to write a while loop and echo HTML form.

10.101.0.169
10.101.0.171
10.101.0.175
10.101.0.177
10.101.0.179
10.101.0.181
10.101.0.185
10.101.0.193

I want some thing like this.

while (file1 has entries)
{ echo "option value=IP address1" }
end

The goal is to publish a HTML form which users can use to select the IP address from drop down menu and click submit and parameters will be passed to a CGI script for further processing.

I am sure someone expert should be able to help me.

Thanks

2 Answers 2

1

Something like this should work in bash way.

while read line
    echo "option value=$line"
done < file_name

If you want it to be in HTML, could be like

echo "<select name=IP>"
while read line
    echo "<option value=$line>$line</option>"
done < file_name
echo "</select>"
Sign up to request clarification or add additional context in comments.

Comments

0

You can use sed:

#! /bin/bash
{
    echo '<select name="ip">'
    sed -e 's|.*|  <option value="&">&</option>|' file
    echo '</select>'
} > out.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.