Archive for January, 2008

Here, options is one or more of the (Web site construction)

Thursday, January 31st, 2008

Here, options is one or more of the options given in Table 23.2. Table 23.2 Options for the uname Command Option Description -a Prints all information -m Prints the current hardware type -n Prints the hostname of the system -r Prints the operating system release level -s Prints the name of the operating system (default) By default, the uname command prints the name of the operating system. The output looks like the following: $ uname Linux Here, the output indicates that the operating system name of the machine is Linux. Usually, this is enough to determine the UNIX version. For example, on FreeBSD systems, the output is FreeBSD and on HP-UX systems the output is HP-UX. The major exception to this is SunOS. Using the Operating System Release Level As previously mentioned, SunOS is the name of the UNIX operating system developed by Sun Microsystems. SunOS was originally based on BSD UNIX but has since changed to be based on System V UNIX. Although Sun Microsystems changed the marketing name of the new version to Solaris, both versions produce the output SunOS when uname is run. To use the correct versions of commands, shell scripts that have to run on both Solaris and the old SunOS must be able to detect the difference between these two versions. To determine whether a system is running Solaris or SunOS, you need to determine the version of the operating system. SunOS versions 5 and higher are Solaris (System V-based); SunOS versions 4 and lower are SunOS (BSD-based). To determine the version of the operating system, use the -r option of uname: $ uname -r 5.5.1 This indicates that the version of the operating system is 5.5.1. If you want to add the operating system’s name to this output, use the -r and the -s options: $ uname -rs SunOS 5.5.1 This indicates the machine is running Solaris. A machine running the BSD-based SunOS displays the
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

System V (sometimes abbreviated as SysV) is the (Web server type)

Wednesday, January 30th, 2008

System V (sometimes abbreviated as SysV) is the latest version of UNIX released by AT&T Bell Labs. It is based on the original version of UNIX developed in the early 1970s. System V UNIX is the standard for commercial versions of UNIX. Both Solaris (the newest version of SunOS) and HP-UX are based on System V UNIX. The main difference between BSD UNIX and System V UNIX is in system administration and networking. System V UNIX is newer than BSD UNIX and provides many standardized tools for configuring a system, installing prepackaged software, and network programming. Also, the layout of the file system in System V UNIX has changed to some extent. Table 23.1 lists the BSD directories and their System V equivalents. Table 23.1 System V Equivalents of BSD Directories BSD System V /bin /usr/bin /sbin /usr/sbin /usr/adm /var/adm /usr/mail /var/mail or /var/spool/mail /usr/tmp /var/tmp The directories /bin and /sbin still exist on some System V-based UNIX versions. On Solaris, these directories are links to /usr/bin and /usr/sbin, respectively. On HP-UX, these directories still contain some commands essential at boot time. The commands stored in these directories are not the same commands as in BSD. Most vendors who have switched from BSD to System V still provide BSD versions in the directory /usr/ucb. In addition to these changes, many System V-based UNIX versions have introduced the directory /opt in an attempt to standardize the installation locations of prepackaged software products. On older systems, many different locations, including /usr, /usr/contrib, and /usr/local, were used to install optional software packages. Linux is hard to classify because it is not based on either BSD or System V source code. It was written from scratch by Linus Torvalds at the University of Helsinki in Finland and is considered by some to be a third type of UNIX that incorporates the best features found in both System V and BSD. The commands and the networking layer in Linux are both based on BSD, whereas the standardized tools for system configuration and installation of prepackaged software are similar to System V. Some of the major vendors of Linux are Caldera and Red Hat. Using uname The first step in writing portable shell scripts is to determine which version of UNIX is executing your shell script. You can determine this using the uname command: uname options
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Sams Teach Yourself Shell Programming in 24 Hours (Free web hosts)

Tuesday, January 29th, 2008

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 23: Scripting for Portability Previous Chapter Next Chapter Sections in this Chapter: Determining UNIX Versions Questions Techniques for Increasing Portability Terms Summary Previous Section Next Section Hour 23 Scripting for Portability Shell programming is an important part of UNIX because shell scripts are portable between different versions of UNIX. In many cases, no changes are required for a shell script to function correctly on multiple systems. The easiest way to ensure that your shell scripts are completely portable is to restrict yourself to using only those commands and features that are available on all versions of UNIX. Sometimes, you have to implement workarounds to deal with the limitations of a particular version of UNIX. In this chapter, you will first learn how to determine which version of UNIX is running. Then you will learn how to adapt your shell scripts to different versions of UNIX by examining some of the problems encountered when porting scripts between the versions. Determining UNIX Versions BSD Versus System V Determining the UNIX Version Using a Function Using uname Before you can begin adjusting shell scripts to be portable, you need to know what the different types of UNIX are and how to tell them apart. The two major types of UNIX are l BSD (Berkeley Software Distribution) l System V The locations of commands and the options supported by certain commands are different between these two types of UNIX. This chapter highlights the major differences and commands in particular. BSD Versus System V BSD UNIX was developed by the Computer Systems Research Group at the University of California at Berkeley. In the early 1980s, the University of California acquired the source code to UNIX from AT&T Bell Labs and significantly modified it to produce BSD UNIX. Although the University of California has stopped distributing BSD UNIX, current versions of it are available from many sources. The most common versions of BSD are OpenBSD, NetBSD, and FreeBSD. Some older machines from Sun Microsystems run a modified version of BSD called SunOS.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Sams Teach Yourself Shell Programming in 24 Hours (Web hosting rating)

Monday, January 28th, 2008

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Terms File System A file system is used by UNIX to store files and directories. Usually a file system corresponds to a hard drive or hard drive partition. Tar File A tape archive file created by the tar command. A tar file can contain both files and directories, making it similar to a zip file. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Web hosting services - MYADDRESSBOOK=”$HOME/addressbook” if [ ! -f “$MYADDRESSBOOK” ] ;

Sunday, January 27th, 2008

MYADDRESSBOOK=”$HOME/addressbook” if [ ! -f “$MYADDRESSBOOK” ] ; then printERROR “$MYADDESSBOOK does not exists, or is not a file.” exit 1 fi and awk -F: ‘{ printf “%-10s %sn%-10s %sn%-10s %sn%-10s %snn”, “Name:”,$1,”Email:”,$2,”Address:”,$3, “Phone:”,$4 ; }’ How might you rewrite these script fragments so that they can be shared between these scripts instead of being replicated in both? 4. The delperson script uses the grep command to generate a list of matching entries. This might confuse the user in the following instance: $ ./delperson.01 to Name: James T. Kirk Email: jim@enterprise.mil Address: 1701 Main Street Anytown Iowa Phone: 555-555-5555 Delete this entry (y/n)? [n] Here the to in Anytown was matched. What changes should be made to the delperson script so that only those entries whose names match the user-specified name are selected for deletion? (HINT: Use the sed command instead of grep). 5. If the delperson script gets a signal while it is processing deletes, all the intermediate files are left behind. What can be done to prevent this? Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Sams Teach Yourself Shell Programming in (Make my own web site) 24 Hours

Saturday, January 26th, 2008

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Questions 1. How might you simplify the following portion of the mvdir script? Specifically, how could you rewrite the main if statement, such that the else clause was unnecessary? 40 if [ -d “$2″ ] ; then 41 42 DESTDIR= ( cd “$2″ ; pwd ; ) 43 44 else 45 46 # if the destination doesn’t exist then 47 # assume the destination is the new name 48 # for the directory 49 DESTDIR=” /usr/bin/dirname $2 ” 50 NEWNAME=” /bin/basename $2 ” 51 52 # if dirname returns a relative dir we will 53 # be confused after cd’ing later on. So 54 # reset it to the full path. 55 DESTDIR= (cd $DESTDIR ; pwd ; ) 56 57 # if the parent of the destination doesn’t 58 # exist, we’re in trouble. Tell the user 59 # and exit. 60 if [ ! -d “$DESTDIR” ] ; then 61 printERROR “A parent of the destination directory $2 does not exist” 62 fi 63 64 fi 65 2. The showperson script lists all matching entries in the address book based on a name provided by the user. The matches produced are case sensitive. How can you change the matches so they aren’t case sensitive? 3. Both the showperson and delperson scripts reproduce exactly the following pieces of code PATH=/bin:/usr/bin # check that a name is given if [ $# -lt 1 ] ; then printUSAGE ” basename $0 name” exit 1 fi # check that the address book exists
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web host sites - Sams Teach Yourself Shell Programming in 24 Hours

Friday, January 25th, 2008

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Summary In this chapter I covered using shell scripts to solve two problems: l Moving directories l Maintaining an address book In the first example, I showed you how to move a directory between file systems using the tar command. This example also showed you how to use the basename and dirname commands to extract parts of a path for your use. In the second example, you developed three scripts that you used to modify and view the contents of an address book. Some of the highlights of these scripts are: l The showperson script showed you how the grep and awk commands can be used to format input. l The addperson script showed you how a single script can be used in both interactive and noninteractive modes. l The delperson script showed you how to use the grep command and file descriptors to update a file accurately. The examples in this chapter demonstrate how you can apply the tools that you have covered in previous chapters to solve real problems. Using these scripts as examples, you can see some of the techniques used to solve everyday problems. In the next chapter I will show you how to make sure the scripts you write are portable between different versions of UNIX. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
You want to have a cheap webhost for your apache application, then check apache web hosting services.

The first main step in the script is (Web hosting ratings)

Thursday, January 24th, 2008

The first main step in the script is to make a copy of the address book (line 49). If this step fails, you exit (line 50). If this step is successful, you make a list of all the lines in the address book that match the name specified by the user (line 55). If you cannot successfully make this file, you exit (line 56). Next you enter the delete loop (lines 60-89). For each line that matches the name provided by the user you print a formatted version of the line (lines 66-69). Notice that you are using the same awk statement from the showperson script. For each matching line, you ask the user whether the entry should be deleted (line 73). If the user agrees (line 74), you do the following: 1. Try to delete the line from the copy of the address book. Store the modified version in a different file (line 79). 2. Replace the copy of the address book with the modified copy (line 84). If either of these operations fail, you exit (lines 80 and 85). After the deletes are finished, you make a backup of the original address book (line 93). Then you replace the address book with the fully edited version (line 98). Again you exit if either operation fails (lines 94 and 99). Finally you clean up and exit. Here is an example of this script in action: $ ./delperson Sriranga Name: Sriranga Veeraraghavan Email: ranga@soda.berkeley.edu Address: 1136 Wunderlich Dr. San Jose CA Phone: 408-444-4444 Delete this entry (y/n)? [n] y Here I replied yes to the question. You can confirm that the delete worked as follows: $ ./showperson Sriranga $ Because there is no output from showperson, this entry has been deleted. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 22: Problem Solving with Shell Scripts Previous Chapter Next Chapter Sections in this Chapter: Moving Directories Questions Maintaining an Address Book Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

73 promptYESNO “Delete this entry” “n” 74 if (Web site development)

Wednesday, January 23rd, 2008

73 promptYESNO “Delete this entry” “n” 74 if [ “$YESNO” = “y” ] ; then 75 76 # try to remove the line, store the updated version 77 # in a new file 78 79 grep -v “$LINE” “$TMPF1″ > “$TMPF1.new” 2> /dev/null 80 Failed $? “Unable to update the address book” 81 82 # replace the old version with the updated version 83 84 mv “$TMPF1.new” “$TMPF1″ 2> /dev/null 85 Failed $? “Unable to update the address book” 86 87 fi 88 done 89 exec 5<&- 90 91 # save the original version 92 93 mv "$MYADDRESSBOOK" "$MYADDRESSBOOK".bak 2> /dev/null 94 Failed $? “Unable to update the address book” 95 96 # replace the original with the edited version 97 98 mv “$TMPF1″ “$MYADDRESSBOOK” 2> /dev/null 99 Failed $? “Unable to update the address book” 100 101 # clean up 102 103 doCleanUp 104 105 exit $? In the first part of the script (lines 8-30), you perform some initialization. Specifically, you perform the following actions: 1. Retrieve the helper functions from libTYSP.sh (line 8) . 2. Check to make sure a name to delete is given (lines 14-17). 3. Check to make sure that the address book exits (lines 21-25). 4. Initialize the variables for the temporary files (lines 29 and 30) and the PATH (line 10). After initialization, you create a few additional helper functions: l doCleanUp, to remove the temporary files (line 34) l Failed, to issue an error message, remove the temporary files and exit if a critical command fails (lines 37-44)
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Web hosting comparison - 19 # check that the address book exists

Tuesday, January 22nd, 2008

19 # check that the address book exists 20 21 MYADDRESSBOOK=”$HOME/addressbook” 22 if [ ! -f “$MYADDRESSBOOK” ] ; then 23 printERROR “$MYADDESSBOOK does not exists, or is not a file.” 24 exit 1 25 fi 26 27 # initialize the variables holding the location of the 28 # temporary files 29 TMPF1=/tmp/apupdate.$$ 30 TMPF2=/tmp/abdelets.$$ 31 32 # function to clean up temporary files 33 34 doCleanUp() { rm “$TMPF1″ “$TMPF1.new” “$TMPF2″ 2> /dev/null ; } 35 36 # function to exit if update failed 37 Failed() { 38 if [ “$1″ -ne 0 ] ; then 39 shift 40 printERROR $@ 41 doCleanUp 42 exit 1 43 fi 44 } 45 46 # make a copy of the address book for updating, 47 # proceed only if sucessful 48 49 cp “$MYADDRESSBOOK” “$TMPF1″ 2> /dev/null 50 Failed $? “Could not make a backup of the address book.” 51 52 # get a list of all matching lines from the address book copy 53 # continue if one or more matches were found 54 55 grep “$1″ “$TMPF1″ > “$TMPF2″ 2> /dev/null 56 Failed $? “No matches found.” 57 58 # prompt the user for each entry that was found 59 60 exec 5< "$TMPF2" 61 while read LINE <&5 62 do 63 64 # display each line formatted 65 66 echo "$LINE" | awk -F: '{ 67 printf "%-10s %sn%-10s %sn%-10s %sn%-10s %snn", 68 "Name:",$1,"Email:",$2,"Address:",$3, "Phone:",$4 ; 69 }' 70 71 # prompt for each line, if yes try to remove the line 72
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.