Archive for July, 2007

Free web design - Sams Teach Yourself Shell Programming in 24 Hours

Tuesday, July 31st, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section Terms File Descriptor An integer that is associated with a file. Enables you to read and write from a file using the integer instead of the file’s name. STDIN Standard Input. User input is read from STDIN. The file descriptor for STDIN is 0. STDOUT Standard Output. The output of scripts is usually to STDOUT. The file descriptor for STDOUT is 1. STDERR Standard Error. A special type of output used for error messages. The file descriptor for STDERR is 2. Escape Sequence An escape sequence is special sequence of characters that represents another character. Output Redirection In UNIX, the process of capturing the output of a command and storing it in a file is called output redirection because it redirects the output of a command into a file instead of the screen. Input Redirection In UNIX the process of sending input to a command from a file is called input redirection. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
We recommend high quality webhost to host and run your jsp application: christian web host services.

Web site builder - Sams Teach Yourself Shell Programming in 24 Hours

Tuesday, July 31st, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section Questions 1. Complete the script using the appropriate printf commands to perform the specified numeric conversions. Assume that the input is always a number: #!/bin/sh if [ $# -lt 2 ] ; then echo “ERROR: Insufficient arguments.” ; exit 1 ; fi case “$1″ in -o) : # convert the number stored in “$2″ into octal ;; -x) : # convert the number stored in “$2″ into hexadecimal ;; -e) : # convert the number stored in “$2″ into scientific notation ;; *) echo “ERROR: Unknown conversion, $1!” ;; esac 2. Rewrite the error messages in the previous script to redirect their output to STDERR instead of STDOUT. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms 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 24 Hours (Cool web site)

Monday, July 30th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section Summary In this chapter, I formally introduced the concept of input and output. I covered the echo and printf commands that are used to produce messages from within shell scripts. I also introduced output redirection, covering the methods of redirecting and appending the output of a command to a file. In addition, I discussed reading input for the first time. I also covered reading in files and reading input from users. Finally, I introduced the concept of a file descriptor and showed several aspects of its use, including opening files for reading and writing, closing files, and redirecting the output of two file descriptors to one source. In the subsequent chapters, I will expand on the material covered here, and you will see many more applications of both input and output redirection along with the use of file descriptors. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

when the while loop exits, the value of (Most popular web site)

Monday, July 30th, 2007

when the while loop exits, the value of $i is not preserved. In this case, you need to change a variable’s value inside the while loop and then use that value outside the loop. You can accomplish this by redirecting the STDIN prior to entering the loop and then restoring STDIN to the terminal after the while loop. The basic syntax is exec n<&0 < file while read LINE do : # manipulate file here done exec 0<&n n<&- Here n is an integer greater than 2, and file is the name of the file you want to read. Usually n is chosen as a small number such as 3, 4, or 5. As an example, you can construct a shell version of the cat command: #!/bin/sh if [ $# -ge 1 ] ; then for FILE in $@ do exec 5<&0 < "$i" while read LINE ; do echo $LINE ; done exec 0<&5 5<&- done fi Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms 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.

n>&m Here n and m are file descriptors (Web hosting solutions)

Sunday, July 29th, 2007

n>&m Here n and m are file descriptors (integers). If you let n=2 and m=1, you see that STDERR is redirected to STDOUT. By redirecting STDOUT to a file, you also redirect STDERR. If m is a hyphen ( -) instead of a number, the file corresponding to the file descriptor n is closed. When a file descriptor is closed, trying to read or write from it results in an error. Reading Files, Another Look One of the most common uses of this form of redirection is for reading files one line at a time. You already looked at using a while loop to perform this task: while read LINE do : # manipulate file here done < file The main problem with this loop is that it is executed in a subshell, thus changes to the script environment, such as exporting variables and changing the current working directory, does not apply to the script after the while loop changes. As an example, consider the following script: #!/bin/sh if [ -f "$1" ] ; then i=0 while read LINE do i= echo "$i + 1" | bc done < "$1" echo $i fi This script tries to count the number of lines in the file specified to it as an argument. Executing this script on the file $ cat dirs.txt /tmp /usr/local /opt/bin /var produces the following output: 0 Although you are incrementing the value of $i using the command i= echo "$i + 1" | bc
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Multiple domain web hosting - command > file 2>&1 list > file 2>&1

Sunday, July 29th, 2007

command > file 2>&1 list > file 2>&1 Here STDOUT (file description 1) and STDERR (file descriptor 2) are redirected into the specified file. Here is a situation where it is necessary to redirect both the standard output and the standard error: rm -rf /tmp/my_tmp_dir > /dev/null 2>&1 ; mkdir /tmp/my_tmp_dir Here, you are not interested in the error message or the informational message printed by the rm command. You only want to remove the directory, thus its output or any error message it prints are redirected to /dev/null. If you had one command that should append its standard error and standard output to a file, you use the following form: command >> file 2>&1 list >> file 2>&1 An example of a command that might require this is rdate -s ntp.nasa.gov >> /var/log/rdate.log 2>&1 Here you are using the rdate command to synchronize the time of the local machine to an Internet time server and you want to keep a log of all the messages. Printing a Message to STDOUT You can also use this form of output redirection to output error messages on STDERR. The basic syntax is echo string 1>&2 printf format args 1>&2 You might also see these commands with the STDOUT file descriptor, 1, omitted: echo string >&2 printf format args >&2 As an example, say that you need to display an error message if a directory is given instead of a file. You can use the following if statement: if [ ! -f $FILE ] ; then echo “ERROR: $FILE is not a file” >&2 ; fi Redirecting Two File Descriptors You can redirect STDOUT and STDERR to a single file by using the general form for redirecting the output of one file descriptor to another:
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

redirected to file2. Often the STDOUT file descriptor, (Shared web hosting)

Saturday, July 28th, 2007

redirected to file2. Often the STDOUT file descriptor, 1, is not written, so a shorter form of the basic syntax is command > file1 2> file2 You can also use the append operator in place of either standard redirect operator: command >> file1 2> file2 command > file1 2>> file2 command >> file1 2>> file2 The first form appends STDOUT to file1 and redirects STDERR to file2. The second form redirects STDOUT to file1 and appends STDERR to file2. The third form appends STDOUT to file1 and appends STDERR to file2. In the following example, I will illustrate using form1 because you are interested in only the output of the command: for FILE in $FILES do ln -s $FILE ./docs >> /tmp/ln.log 2> /dev/null done Here the STDOUT of ln is appended to the file /tmp/ln.log, and the STDERR is redirected to the file /dev/null, in order to discard it. Tip - The file /dev/null is a special file available on all UNIX systems used to discard output. It is sometimes referred to as the bit bucket . If you redirect the output of a command into /dev/null, it is discarded. You see it used for this purpose often. For example, the command rm file > /dev/null discards the output of the rm command. If you use cat to display the contents of /dev/null to a file, the file’s contents are erased: $ cat /dev/null > file After this command, the file still exists, but its size is zero. Redirecting STDOUT and STDERR to the Same File You looked at how to use file descriptors to redirect STDOUT and STDERR to different files, but sometimes you need to redirect both to the same file. In general, you do this by
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

$ exec 4>fd4.out associates (Web design programs) the file fd4.out with

Saturday, July 28th, 2007

$ exec 4>fd4.out associates the file fd4.out with the file descriptor 4. To open a file for reading, you use the following form: exec n file command n>> file Here command is the name of a command, such as ls, n is a file descriptor (integer), and file is the name of the file. The first form redirects the output of command to the specified file, whereas the second form appends the output of command to the specified file. For example, you can write the standard output redirection forms in the general form as command 1> file command 1>> file Here the 1 explicitly states that STDOUT is being redirected into the given file. General input redirection is similar to general output redirection. It is performed as follows: command n file1 2> file2 Here the STDOUT of the specified command is redirected to file1, and the STDERR (error messages) is
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Php web hosting - Sams Teach Yourself Shell Programming in 24 Hours

Saturday, July 28th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms Previous Section Next Section File Descriptors Associating Files with a File Descriptor General Input/Output Redirection When you issue any command, three files are opened and associated with that command. In the shell, each of these files is represented by a small integer called a file descriptor. A file descriptor is a mechanism by which you can associate a number with a filename and then use that number to read and write from the file. Sometimes file descriptors are called file handles . The three files opened for each command along with their corresponding file descriptors are l Standard Input (STDIN), 0 l Standard Output (STDOUT), 1 l Standard Error (STDERR), 2 The integer following each of these files is its file descriptor. Usually, these files are associated with the user’s terminal, but they can be redirected into other files. In the previous examples in this chapter, you have used input and output redirection using the default file descriptors. This section introduces the general form of input and output redirection. First you examine associating files with a file descriptor. Associating Files with a File Descriptor By default, the shell provides you with three standard file descriptors for every command. With it, you can also associate any file with file descriptors using the exec command. Associating a file with a file description is useful when you need to redirect output or input to a file many times but you don’t want to repeat the filename several times. To open a file for writing, use one of the following forms: exec n>file exec n>>file Here n is an integer, and file is the name of the file you want to open for writing. The first form overwrites the specified file if it exists. The second form appends to the specified file. For example, the following command
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

“Miscellaneous Tools,” I will show (Web hosting servers) you how to

Friday, July 27th, 2007

“Miscellaneous Tools,” I will show you how to use more powerful filters in place of the case statement used here. Pipelines Most commands in UNIX that are designed to work with files can also read input from STDIN. This enables you to use one program to filter the output of another. This is one of the most common tasks in shell scripting: having one program manipulate the output of another program. You can redirect the output of one command to the input of another command using a pipeline, which connects several commands together with pipes as follows: command1 | command2 | … The pipe character, |, connects the standard output of command1 to the standard input of command2, and so on. The commands can be as simple or complex as are required. Here are some examples of pipeline commands: tail -f /var/adm/messages | more ps -ael | grep “$UID” | more In the first example, the standard output of the tail command is piped into the standard input of the more command, which enables the output to be viewed one screen at a time. In the second example, the standard output of ps is connected to the standard input of grep, and the standard output of grep is connected to the standard input of more, so that the output of grep can be viewed one screen at a time. For now, simply be aware of this technique of redirection. I show you how to use it to filter text in Chapters 16, 17, and 18. Caution - One important thing about pipelines is that each command is executed as a separate process, and the exit status of a pipeline is the exit status of the last command. It is vital to remember this fact when writing scripts that must do error handling. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 13: Input/Output Previous Chapter Next Chapter Sections in this Chapter: Output Summary Input Questions File Descriptors Terms 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.