Archive for November, 2007

if [ $YN = “y” ] (Dedicated web hosting) ; then

Friday, November 30th, 2007

if [ $YN = “y” ] ; then Making this change, you find that the syntax of the script is okay because the command $ /bin/sh -n buggy1.sh produces no output. Why You Should Use Syntax Checking After looking at the shell script in the previous example, you might be wondering why you couldn’t simply execute the shell script to determine the problem. After all, the command $ /bin/sh ./buggy1.sh produces the output buggy1.sh: syntax error at line 7: ‘fi’ unexpected This output is identical to the output of the following command: $ /bin/sh -n ./buggy1.sh For this script, it does not matter whether you use the syntax checking mode, but this is not always the case. As an example, consider the following script (the line numbers are included for your reference): 1 #!/bin/sh 2 3 Failed() { 4 if [ $1 -ne 0 ] ; then 5 echo “Failed. Exiting.” ; exit 1 ; 6 fi 7 echo “Done.” 8 } 9 10 echo “Deleting old backups, please wait… c” 11 rm -r backup > /dev/null 2>&1 12 Failed $? 13 14 echo “Make backup (y/n)? c” 15 read RESPONSE 16 case $RESPONSE in 17 [yY]|[Yy][Ee][Ss]|*) 18 echo “Making backup, please wait… c” 19 cp -r docs backup 20 Failed 21 [nN]|[Nn][Oo]) 22 echo “Backup Skipped.” ;;
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

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

Thursday, November 29th, 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 Syntax Checking Why You Should Use Syntax Checking Using Verbose Mode When dealing with any shell script, check the syntax of the script before trying to execute it. This enables you to fix most problems. To enable syntax checking, use the -n option as follows: /bin/sh -n script arg1 arg2 … argN Here script is the name of a script and arg1 through argN are the arguments for that script. This command generates output only if errors occur in the specified script. Check the syntax of the following script (the line numbers are included for your reference): 1 #!/bin/sh 2 3 YN=y 4 if [ $YN = “yes” ] 5 echo “yes” 6 fi Can you spot the error? If this script is stored in the file buggy1.sh, check its syntax as follows: $ /bin/sh -n ./buggy1.sh The output looks like the following: ./buggy1.sh: syntax error at line 7: ‘fi’ unexpected This tells you that when the shell tried to read line 7, it found that the fi statement on line 6 was unexpected. By now you have probably figured out that the reason the shell was trying read line 7 is that the if statement on line 4 if [ $YN = “y” ] is not terminated with a then statement. This line should read as follows:
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Here the debugging mode is enabled just before (Jetty web server)

Wednesday, November 28th, 2007

Here the debugging mode is enabled just before the function is called and is disabled when the function completes. This method is favored over explicitly using the set command inside a function to enable debugging because it enables the implementation of the function to remain unchanged. 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.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Anonymous web server - Consider the following excerpt from a shell script

Tuesday, November 27th, 2007

Consider the following excerpt from a shell script (the line numbers are provided for your reference): 1 #!/bin/sh 2 set -x 3 if [ -z “$1″ ] ; then 4 echo “ERROR: Insufficient Args.” 5 exit 1 6 fi Here the shell programmer is requesting that shell tracing (the -x option) be activated with the command from line 2: set -x Because this command occurs before the if statement (lines 3 through 6), shell tracing will be active while the if statement executes. Unless it is explicitly disabled later in the script, shell tracing remains in effect until the script exits. You will learn about the effect that shell tracing has on the output of a script in the “Shell Tracing” section of this chapter. Disabling Debugging Using set In addition to enabling debugging modes, you can use the set command to disable debugging modes as follows: set +option Here option is the letter corresponding to one of the options given in Table 20.1. For example, the command $ set +x disables the shell tracing debugging mode. All the debugging modes that are enabled for a script can be deactivated using the following command: $ set - Enabling Debugging for a Single Function One of the most common uses of the set command is to enable a particular debugging mode before a function executes and then disable debugging when the function finishes. For example, if you have a function called BuggyFunction() and you only want to enable the shell tracing debugging mode while that function executes, use the following command: set -x ; BuggyFunction; set +x ;
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Post office web site - A third way of enabling debugging is to

Monday, November 26th, 2007

A third way of enabling debugging is to change the first line of the script. Usually, the first line of a script is #!/bin/sh UNIX uses this line to determine the shell you can use to execute a script. This indicates that the shell /bin/sh should be used to execute the script. Modify this line to specify a debugging option as follows: #!/bin/sh option Here option is one of the debugging options listed in Table 20.1. Because the previously mentioned methods for enabling debugging modes take effect when a script is invoked, they are sometimes referred to as invocation activated debugging modes. Table 20.1 Debugging Options for Shell Scripts Option Description -n Reads all commands, but does not execute them. -v Displays all lines as they are read. -x -Displays all commands and their arguments as they execute. This option is often referred to as the shell tracing option. Using the set command In one of the invocation activated debugging modes, the default behavior is for that debugging mode to take effect at the first line of your script and remain in effect until the last line. Sometimes you just need to debug a particular function or section of your script. In these cases, enabling debugging for the entire script is overkill. As you see later in this chapter, the debugging output is quite extensive, and it is often hard to sort out the real errors from the noise. Address this problem with the set command to enable the debugging modes. By using the set command, you can enable and disable debugging at any point in your shell script. Enabling Debugging Using set The basic syntax follows: set option Here option is one of the options given in Table 20.1. You can use the set command anywhere in your shell script, and many scripts use it to change the debugging flags as part of the normal execution of the script. Because these debugging modes are activated only when the shell script programmer uses the set command, they are sometimes referred to as “programmer activated” modes.
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Sams Teach Yourself Shell Programming in 24 Hours (Web server address)

Sunday, November 25th, 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 Hour 20 Debugging In this book you have looked at scripts that are quite short. Thus, the issue of debugging them has boiled down to looking at their output and making sure it is correct. For larger shell scripts, especially the kind that change system configurations, trying to deduce the source of a problem from a script’s output is insufficient. Often, by the time you get the output, it is too late–the script will have made incorrect modifications or changes. Another common scenario is adding features to a large script that someone else developed. In such cases you need to make sure your changes don’t affect the rest of the script. Fortunately, the shell provides several built-in commands for enabling different modes of debugging support. In this chapter you learn how to enable debugging, and then you will look at how to use the following debugging modes: l Syntax checking l Shell tracing Enabling Debugging By now, you are quite familiar with the basic syntax for executing a shell script: $ script arg1 arg2 … argN Here script is the name of the script, and arg1 through argN are the arguments to the script. A frequently used alternative method to execute a shell script is $ /bin/sh script arg1 arg2 … argN Here you explicitly specify the shell, in this case /bin/sh, that you used to execute the script. The advantage of this method is that you can enable a debugging mode by supplying arguments to the shell. Using this method of script invocation, the basic syntax for enabling a debugging mode is $ /bin/sh option script arg1 arg2 … argN Here option is one of the debugging options covered in Table 20.1.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Web hosting provider - Sams Teach Yourself Shell Programming in 24 Hours

Saturday, November 24th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 19: Dealing with Signals Previous Chapter Next Chapter Sections in this Chapter: How Are Signal Represented? Conclusion Dealing with Signals Questions Previous Section Next Section Questions 1. The following is the main body of the “alive” script presented earlier in this chapter. Please change it so that receiving a SIGQUIT causes it to exit when the wait command returns. # main() trap CleanUp 2 3 15 trap Init 1 PROG=$1 Init while : ; do wait $! $PROG & done 2. Add a signal handler to the timer script to handle the INT signal. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 19: Dealing with Signals Previous Chapter Next Chapter Sections in this Chapter: How Are Signal Represented? Conclusion Dealing with Signals Questions Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Most popular web site - Sams Teach Yourself Shell Programming in 24 Hours

Friday, November 23rd, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 19: Dealing with Signals Previous Chapter Next Chapter Sections in this Chapter: How Are Signal Represented? Conclusion Dealing with Signals Questions Previous Section Next Section Conclusion In this chapter, I introduced the concept of signals. Signals inform a program or script that an important event has occurred. You learned about the most common signals encountered in shell programming. I also listed several methods of obtaining a complete list of all the signals understood by your system. In this section you also covered the concept of delivering signals and the default actions associated with a signal. In the second section of this chapter I introduced the three main methods of handling a signal in a script. Now you know how to catch signals and handle them using signal handlers. You also know how to ignore signals. Finally I showed you how to use signals to set up a timer inside your scripts. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 19: Dealing with Signals Previous Chapter Next Chapter Sections in this Chapter: How Are Signal Represented? Conclusion Dealing with Signals Questions Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web site counters - if [ $? -eq 0 ] ; then

Tuesday, November 20th, 2007

if [ $? -eq 0 ] ; then echo “Sub-processes killed.” ; fi } SetTimer() { DEF_TOUT=${1:-10}; if [ $DEF_TOUT -ne 0 ] ; then sleep $DEF_TOUT && kill -s 14 $$ & CHPROCIDS=”$CHPROCIDS $!” TIMERPROC=$! fi } UnsetTimer() { kill $TIMERPROC } # main() trap AlarmHandler 14 SetTimer 15 $PROG & CHPROCIDS=”$CHPROCIDS $!” wait $! UnsetTimer echo “All Done.” exit 0 Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 19: Dealing with Signals Previous Chapter Next Chapter Sections in this Chapter: How Are Signal Represented? Conclusion Dealing with Signals Questions 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.

Web hosting bandwidth - echo “Sub-processes killed.” ; fi } SetTimer The

Monday, November 19th, 2007

echo “Sub-processes killed.” ; fi } SetTimer The next task that you perform is to set the timer using the SetTimer function: SetTimer() { DEF_TOUT=${1:-10}; if [ $DEF_TOUT -ne 0 ] ; then sleep $DEF_TOUT && kill -s 14 $$ & CHPROCIDS=”$CHPROCIDS $!” TIMERPROC=$! fi } This function takes a single argument that indicates the number of sections that it should set a timer for. The default is 10 seconds. As you can see, setting the timer is fairly trivial. All you do is issue a sleep command with a timeout and then use the kill command to send the shell’s process ID (stored in $$) an ALARM signal. In order to continue processing, you place this timer command in the background. Because the timer is a background process, you need to update the list of child processes with its ID. You also save the process ID of the timer in the variable TIMERPROC so that you can later unset the timer. UnsetTimer The last function is the UnsetTimer function that unsets the timer set by the SetTimer function. Unsetting the timer basically means killing its process: UnsetTimer() { kill $TIMERPROC } The Complete Timer Script The complete timer script follows: #! /bin/sh AlarmHandler() { echo “Got SIGALARM, cmd took too long.” KillSubProcs exit 14 } KillSubProcs() { kill ${CHPROCIDS:-$!}
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.