Archive for December, 2007

The output will be normal if the script (Web hosting reviews)

Tuesday, December 11th, 2007

The output will be normal if the script executes in either of the following methods: $ /bin/sh ./buggy3.sh $ ./buggy3.sh The output includes shell tracing if the same script executes in either of the following methods: $ DEBUG=true /bin/sh ./buggy3.sh $ DEBUG=true ./buggy3.sh Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 20: Debugging Previous Chapter Next Chapter Sections in this Chapter: Enabling Debugging Summary Syntax Checking Questions Shell Tracing 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.

To deactivate debugging, use either of the following: (Web hosting ratings)

Monday, December 10th, 2007

To deactivate debugging, use either of the following: Debug Debug off Actually, any argument passed to this function other than on or ON deactivates debugging. As an example of using this function, modify the functions in the script buggy3.sh to have debugging automatically enabled if the variable DEBUG is set. The modifications are as follows: #!/bin/sh Debug() { if [ “$DEBUG” = “true” ] ; then if [ “$1″ = “on” -o “$1″ = “ON” ] ; then set -x else set +x fi fi } Failed() { Debug on if [ “$1″ -ne 0 ] ; then echo “Failed. Exiting.” ; exit 1 ; fi echo “Done.” Debug off } YesNo() { Debug on echo “$1 (y/n)? c” read RESPONSE case “$RESPONSE” in [yY]|[Yy][Ee][Ss]) RESPONSE=y ;; *) RESPONSE=n ;; esac Debug off } YesNo “Make backup” if [ “$RESPONSE” = “y” ] ; then echo “Deleting old backups, please wait… c” rm -r backup > /dev/null 2>&1 Failed $? echo “Making new backups, please wait… c” cp -r docs backup Failed $? fi
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

My web site - change the read command, you need to look

Sunday, December 9th, 2007

change the read command, you need to look for some other method of solving this problem. This leads you to a logical problem–the case statement is not validating the user input. A simple fix is the following: YesNo() { echo “$1 (y/n)? c” read RESPONSE case “$RESPONSE” in [yY]|[Yy][Ee][Ss]) RESPONSE=y ;; *) RESPONSE=n ;; esac } Here you treat all responses other than “yes” responses as negative responses, including no response at all. Using Debugging Hooks In the previous examples, you were able to deduce the location of a bug by using shell tracing for either the entire script or for part of the script. In the case of enabling tracing for a part of a script, you had to edit the script to insert the debug command: set -x In larger scripts, a more common practice is to embed debugging hooks . Debugging hooks are functions that enable shell tracing during functions or critical code sections. They are activated in one of two ways: l The script is run with a particular command line option (commonly -d or -x). l The script is run with an environment variable set to true (commonly DEBUG=true or TRACE=true). Here is a function that enables you to activate and deactivate debugging at will if the variable DEBUG is set to true: Debug() { if [ “$DEBUG” = “true” ] ; then if [ “$1″ = “on” -o “$1″ = “ON” ] ; then set -x else set +x fi fi } To activate debugging, use the following: Debug on
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

If you do not type a response and (Web server certificate)

Saturday, December 8th, 2007

If you do not type a response and press Enter, the script reports an error similar to the following: ./buggy3.sh: [: =: unary operator expected To determine where this error occurs, it is best to run the entire script in shell tracing mode: $ /bin/sh -x ./buggy3.sh The output is similar to the following: + YesNo Make backup + echo Make backup (y/n)? c + /bin/echo Make backup (y/n)? c Make backup (y/n)? + read RESPONSE + [ = y ] ./buggy3.sh: [: =: unary operator expected Here the blank line is the result of pressing Enter instead of typing a response to the prompt, as you can see from the next line that the shell executes: [ = y ] This is part of the if statement: if [ $RESPONSE = “y” ] ; then Although this can be fixed by changing the if statement if [ “$RESPONSE” = “y” ] ; then the correct fix for this problem is to track down the reason why the variable RESPONSE is not set. This variable is set by the function YesNo: YesNo() { echo “$1 (y/n)? c” read RESPONSE case $RESPONSE in [yY]|[Yy][Ee][Ss]) RESPONSE=y ;; [nN]|[Nn][Oo]) RESPONSE=n ;; esac } There are two problems with this script. The first is that the read command read RESPONSE does not set a value for RESPONSE if the user presses Enter without typing some input. Because you cannot
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

} you find that there is only one (Simple web server)

Friday, December 7th, 2007

} you find that there is only one numerical test. This test compares $1, the first argument to the function, to see whether it is equal to 0. Now the problem should be obvious. When you invoked the Failed function echo “Making new backups, please wait… c” cp -r docs backup Failed you forgot to give it an argument, thus the numeric test failed. There are two possible fixes to this bug. The first is to fix the code that calls the function: echo “Making new backups, please wait… c” cp -r docs backup Failed $? The second is to fix the function itself by quoting the first argument, “$1″: Failed() { if [ “$1″ -ne 0 ] ; then echo “Failed. Exiting.” ; exit 1 ; fi echo “Done.” } By quoting the first argument, “$1″, the shell uses the null or empty string when the function is called without any arguments. In this case the numeric test will not fail because both num1 and num2 have a value. The best idea is to perform both fixes. After these fixes are applied, the shell tracing output is similar to the following: Make backup (y/n)? y Deleting old backups, please wait… Done. + echo Making new backups, please wait… c Making new backups, please wait… + cp -r docs backup + Failed + [ -ne 0 ] + echo Done. Done. + set +x Finding Logical Bugs Using Shell Tracing As mentioned before, there is at least one logical bug in this script. With the help of shell tracing, you can locate and fix this bug. Consider the prompt produced by this script: Make backup (y/n)?
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Deleting old backups, please wait… Done. Making new (Best web site)

Thursday, December 6th, 2007

Deleting old backups, please wait… Done. Making new backups, please wait… buggy3.sh: test: argument expected On Linux systems, the output might vary slightly. In any case, an error message is generated. Because this doesn’t state which line of the script the error occurs on, you need to track it down manually. From the output you know that the old backup was deleted successfully; therefore, the error is probably in the following part of the script: echo “Making new backups, please wait… c” cp -r docs backup Failed Enable shell tracing for this section as follows: set -x echo “Making new backups, please wait… c” cp -r docs backup Failed set +x The output changes as follows (assuming you answer y to the question): Make backup (y/n)? y Deleting old backups, please wait… Done. + echo Making new backups, please wait… c Making new backups, please wait… + cp -r docs backup + Failed + [ -ne 0 ] buggy3.sh: test: argument expected The execution trace varies slightly on Linux systems. From this output you can see that the problem occurred in the following statement: [ -ne 0 ] From Chapter 10, “Flow Control”, you know that the form of a numerical test command is [ num1 operator num2 ] Here it looks like num1 does not exist. Also from the trace you can tell that this error occurred after executing the Failed function. Looking at the function Failed() { if [ $1 -ne 0 ] ; then echo “Failed. Exiting.” ; exit 1 ; fi echo “Done.”
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Web hosting asp - In the preceding example, you used the script

Wednesday, December 5th, 2007

In the preceding example, you used the script buggy2.sh. One of the problems with this script is that it deleted the old backup before asking whether you wanted to make a new backup. To solve this problem, the script is rewritten as follows: #!/bin/sh Failed() { if [ $1 -ne 0 ] ; then echo “Failed. Exiting.” ; exit 1 ; fi echo “Done.” } YesNo() { echo “$1 (y/n)? c” read RESPONSE case $RESPONSE in [yY]|[Yy][Ee][Ss]) RESPONSE=y ;; [nN]|[Nn][Oo]) RESPONSE=n ;; esac } YesNo “Make backup” if [ $RESPONSE = “y” ] ; then echo “Deleting old backups, please wait… c” rm -fr backup > /dev/null 2>&1 Failed $? echo “Making new backups, please wait… c” cp -r docs backup Failed fi There are at least three syntax bugs in this script and at least one logical oversight. See if you can find them. Assuming that the script is called buggy3.sh, first check its syntax as follows: $ /bin/sh -n ./buggy3.sh Because there is no output, execute it: $ /bin/sh ./buggy3.sh The script first prompts you as follows: Make backup (y/n)? Answering y to this prompt produces output similar to the following:
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Sams Teach Yourself Shell (Web site directory) Programming in 24 Hours

Wednesday, December 5th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 20: Debugging Previous Chapter Next Chapter Sections in this Chapter: Enabling Debugging Summary Syntax Checking Questions Shell Tracing Previous Section Next Section Shell Tracing Finding Syntax Bugs Using Shell Tracing Using Debugging Hooks Finding Logical Bugs Using Shell Tracing There are many instances when syntax checking gives your script a clean bill of health, but bugs are still lurking in your script. Running syntax checking on a shell script is similar to running a spelling checker on a text document–it might find most of the misspellings, but it can’t fix problems like spelling read as red. For text documents, you need to proofread them in order to find and fix all misspellings. To find and fix these types of problems in shell scripts, you need to use shell tracing. In shell tracing mode the shell prints each command in the exact form in which it executes. For this reason, you sometimes see the shell tracing mode referred to as the execution tracing mode. The shell tracing or execution tracing mode is enabled by using the -x option ( x as in execution). For a complete script, it is enabled as follows: $ /bin/sh -x script arg1 arg2 … argN As was mentioned before, it can also be enabled using the set command: set -x To get an idea of what the output of shell tracing looks like, try the following command: $ set -x ; ls *.sh ; set +x The output is similar to the following: + ls buggy.sh buggy1.sh buggy2.sh buggy3.sh buggy4.sh buggy.sh buggy1.sh buggy2.sh buggy3.sh buggy4.sh + set +x In the output, the lines preceded by the plus ( +) character are the commands that the shell executes. The other lines are the output from those commands. As you can see from the output, the shell prints the exact ls command it executes. This is extremely useful in debugging because it enables you to determine whether all the substitutions were performed correctly. Finding Syntax Bugs Using Shell Tracing
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Sams Teach Yourself Shell Programming in 24 Hours (Kids web site)

Tuesday, December 4th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 20: Debugging Previous Chapter Next Chapter Sections in this Chapter: Enabling Debugging Summary Syntax Checking Questions Shell Tracing Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Sams Teach Yourself Shell (Web site traffic) Programming in 24 Hours

Monday, December 3rd, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 20: Debugging Previous Chapter Next Chapter Sections in this Chapter: Enabling Debugging Summary Syntax Checking Questions Shell Tracing 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.