Question

Shell script: Obtain IP Address of a Network Interface: User input interface Output should be: $...

Shell script:

Obtain IP Address of a Network Interface:
User input interface

Output should be:

$ ./admino -i en0
Your ip for en0 interface is:10.0.1.10

Homework Answers

Answer #1

Answer:

for iface in $(ifconfig | cut -d ' ' -f1| tr '\n' ' ')
do 
  addr=$(ip -o -4 addr list $iface | awk '{print $4}' | cut -d/ -f1)
  printf "Your ip for $iface interface is: $addr"
done

Output:

Please give thumbsup, or do comment in case of any query. Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
a) An IP address is a number that uniquely identifies a device within a computer network....
a) An IP address is a number that uniquely identifies a device within a computer network. This address can be derived from a General Network Address. i. Using any network address of your choice, explain how you would generate IP addresses by subnet masking. ii. Briefly explain the concept of Host Address and Network Address.
Your company has a policy to use the first IP address in a network as the...
Your company has a policy to use the first IP address in a network as the default gateway address. You have been instructed to configure a new server with an IP address of 192.168.184.227 and a subnet mask of 255.255.255.248. What is the network address for this network? What is the default gateway for this server? Reflection Why is the subnet mask important in determining the network address?
Given the IP address 172.16.45.0 and the mask 255.255.224.0, what is the corresponding network address? Show...
Given the IP address 172.16.45.0 and the mask 255.255.224.0, what is the corresponding network address? Show how you arrived at your answer.
You are configuring two PCs for your network. PC-A is given an IP address of 10.0.0.16,...
You are configuring two PCs for your network. PC-A is given an IP address of 10.0.0.16, and PC-B is given an IP address of 10.1.14.68. Both PCs receive a subnet mask of 255.254.0.0. What is the network address for PC-A? What is the network address for PC-B? Will these PCs be able to communicate directly with each other? What is the lowest address that can be given to PC-B that allows it to be on the same network as PC-A?
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
You have configured your servers IP address as static (192.168.200.10) and installed the DHCP Server role...
You have configured your servers IP address as static (192.168.200.10) and installed the DHCP Server role on your server. You now want to verify it is working. You configure your client to Obtain IP address Automatically and then you reboot the client, log in, and run ipconfig at the command prompt. However, the IP address of your client is 169.254.116.23! (Assume there are no other DHCP servers available on the network, that the server and client are powered on, that...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of userids on the command line 2. For each userid, display the userid, PID, CPU time, and current command for each process owned by that userid Your output should look similar to this example: practice-script-a doug.jones User: doug.jones PID: 8748 TIME: 00:00:00 COMMAND: /usr/lib/systemd/systemd --user User: doug.jones PID: 8749 TIME: 00:00:00 COMMAND: (sd-pam)    User: doug.jones PID: 8750 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/5 User: doug.jones...
Given the following IP address from the Class B address range using the default subnet mask:...
Given the following IP address from the Class B address range using the default subnet mask: 100.110.0.0. Your network plan requires no more than 64 hosts on a subnet. When you configure the IP address in Cisco IOS software, which value should you use as the subnet mask? a) 255.255.0.0 b) 255.255.128.0 c) 255.255.255.128 d) 255.255.255.252 If your current Network ID is 223.40.35.0 with the default subnet mask and you need to have 15 subnets and maximizing the number of...
Write a PHP script that tests whether an e-mail address is input correctly. Verify that the...
Write a PHP script that tests whether an e-mail address is input correctly. Verify that the input begins with series of characters, followed by the @ character, another series of characters, a perod (.) and a final series of characters. Test your program, using both valid and invalid e-mail address. Please make sure it outputs valid or invalid address
You are the WAN engineer for Widgets International. Your company has just purchased the IP network...
You are the WAN engineer for Widgets International. Your company has just purchased the IP network range 201.144.32.0/24. Your company needs two networks with 48 hosts per network using this IP network range. How do you subnet this IP network? What is the subnet mask you should use? What network address would you use? How would you write this in CIDR notation? What are the usable networks and ranges that you can use to accomplish your company s directive?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT