Need Help With making this script

Hello, im a new user on this site and learning scripting very slowly at a understanding pace. However i am up with a challenge and require help completing this.

The script has to include arguments, variables, decisions and loops. So the script is about calculating the broadcast address for any given IP address and subnet mask...below is the layout of script details, Any help?

$ ./my_broadcast_calc 172.16.200.123/255.255.255.0


            172.16.200.255


 $ ./my_broadcast_calc 172.16.200.123/25


            172.16.200.255


 $ ./my_broadcast_calc 172.16.200.123/0xffffff00 -hex


            0xac10c8ff


 

The script should be able to handle the option �hex (which means display the final output in hexadecimal format). If the option is not provided, the the script should always display the result as in decimal (base 10) format.

Is this a homework assignment?

This is assignment from my course. The thing is i never learned how to deal with IP addresses in scripting :confused:

There is a separate forum for homework and I'm sure Don will fill you in on the rules around this.

As source of some related code have a look the following thread pinned on this forum:

http://www.unix.com/shell-programming-and-scripting/233825-convert-ip-ranges-cidr-netblocks.html

Thanks Chubler_XL, i dont even know where to begin with this question. I feel like im naked in the cold alone lol. Hope some expert that can guide me with this :slight_smile:

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulted in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.