How do I determine whether the shell (Web hosting script) can

How do I determine whether the shell can find a particular command? You can check to make sure that the shell can find a command or shell function by using the type command covered in Chapter 18, “Miscellaneous Tools”: type name > /dev/null 2>&1 ; if [ $? -ne 0 ] ; then list ; fi Here name is the name of the command you want check for, and list is the list of commands to execute if the shell does not know about name. Usually list is used to determine a fallback command. The type command is a builtin in sh and bash. In ksh, it is usually an alias, whence -v. How do I determine whether job control is available in the shell? Job control, covered in Chapter 6, “Processes,” is the shell feature that enables you to control background processes based on a job ID. This feature is not available in the Bourne shell, sh. It is available in ksh and bash. A common method used to check whether job control is enabled is to check whether the jobs command is defined: if type jobs > /dev/null 2>&1 ; then echo “We have job control” fi This check is effective in most cases because the jobs command is not available in most versions of the Bourne shell. Unfortunately, some versions of UNIX such as Sun Solaris, include a version of the Bourne shell that has a built-in command called jobs. On these systems when the shell is invoked as /bin/sh, the jobs command exists but does nothing. If the shell is invoked as /bin/jsh (as in job control shell), the jobs command behaves normally. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 24: Shell Programming FAQs Previous Chapter Next Chapter Sections in this Chapter: Shell and Command Questions File and Directory Questions Variable and Argument Questions Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Leave a Reply