You can also define your own file descriptors, and use them in creative and useful ways within your scripts: http://tldp.org/LDP/abs/html/io-redirection.html On Thu, May 12, 2011 at 1:52 PM, Dale Farnsworth wrote: >> Hi, >> >> I keep seeing a reference to what looks like two pre-populated variables >> in shell scripts.  Actually this one is in a crontab. >> >> Something like this :  /home/user-name/directory-name/scriptname.php >> >/dev/null 2>&1 >> >> What is the number 1 and 2?  Is there others? > > Unix and copycats, like Linux use small non-negative integers to identify > files that may be read from or written to.  They are known as file > descriptors.  By convention, the first 3 file descriptors have a special > meaning.  0 is standard input, 1 is standard output, and 2 is standard > error. > > Normally, each process inherits these 3 file descriptors from its > parent process but the shell allows you to "redirect" them to > other files. > > Examples: >        echo hello >newfile     # Creates the file "newfile" and writes >                                # "hello\n" to it. >        echo hello >/dev/null   # Writes "hello\n" to /dev/null, where it >                                # disappears >        echo hello 2>newfile2   # Creates the file "newfile2" and puts >                                # error messages from "echo hello" into it. >                                # Since "echo hello" won't output any error >                                # messages, "newfile2" will be an empty file. >        echo hello 2>&1         # Redirects the error output of the command >                                # into the same file where the standard >                                # output goes. > > So, "scriptname.php >/dev/null 2>&1" says to redirect the standard output > of scriptname.php into the bit bucket and then to redirect the standard > error output to the same place. > > -Dale > > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > To subscribe, unsubscribe, or to change your mail settings: > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss > --------------------------------------------------- PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us To subscribe, unsubscribe, or to change your mail settings: http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss