Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
18 CHAPTER 1 Introduction to command shell scripting Improving the script There are a number of ways we can improve the port scanner script to make it more efficient and more functional: · We presently can't handle scanning multiple hosts. We could add this capability by including provisions for additional arguments, or by reading hosts or IPs in from a file. · In the pingcheck function, when we encounter a device that does not respond to our ping, we have to wait several seconds for the ping command to return and tell us so. If we include a timeout in the ping command, we can likely shorten this considerably. · In this portcheck function, we are only testing Transmission Control Protocol (TCP) ports. If we want to test User Datagram Protocol (UDP) ports as well, we can make use of the /dev/udp device in a very similar fashion to our existing code. We would also need to include the appropriate arguments to indicate whether we wanted to scan TCP ports, UDP ports, or both. These are only a few of the many additional features we might add in order to increase functionality, make the script work more efficiently, and generally make the