- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
crystal reports barcode label printing DATA REDIRECTION in Font
CHAPTER 9 DATA REDIRECTION Drawing Data Matrix 2d Barcode In None Using Barcode generator for Font Control to generate, create Data Matrix image in Font applications. www.OnBarcode.comMake Code-39 In None Using Barcode maker for Font Control to generate, create Code-39 image in Font applications. www.OnBarcode.comAny combination of the following exec commands can be used in your code to open a file and assign it a single-digit file descriptor: exec 3> file_1: Opens file_1 for output in overwrite mode, which would then be accessed with file descriptor 3. exec 4< file_2: Opens file_2 for input in read mode, which would then be accessed with file descriptor 4. exec 5>> file_3: Opens file_3 for output in append mode, which would then be accessed with file descriptor 5. exec 6<> file_4: Opens file_4 for both reading and writing, which would then be accessed with file descriptor 6. Unlike the other examples, where you must access the files in the same way the descriptors were opened, for either reading or writing, this type of descriptor can be accessed in both ways. Once the file descriptors are open, you can access them with various input or output statements. To access a specific open file descriptor, complete an expression with the syntax >&fd, where fd denotes the single-digit descriptor. Here are some examples of reading and writing to open files: Making EAN / UCC - 14 In None Using Barcode creation for Font Control to generate, create UCC-128 image in Font applications. www.OnBarcode.comCode 128 Code Set A Generator In None Using Barcode printer for Font Control to generate, create Code 128 Code Set B image in Font applications. www.OnBarcode.comecho "The quick brown fox jumped over the lazy dog" >&3 grep 172.16 /etc/hosts >&5 read line <&4 EAN13 Drawer In None Using Barcode maker for Font Control to generate, create GTIN - 13 image in Font applications. www.OnBarcode.comBarcode Generator In None Using Barcode maker for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comI have matched the file-descriptor numerals (relating to input and output) with the exec commands that opened them originally. Using the exec syntax you can also specify your output at runtime instead of hardcoding it. The following example demonstrates the technique: PDF-417 2d Barcode Maker In None Using Barcode creation for Font Control to generate, create PDF 417 image in Font applications. www.OnBarcode.comRoyal Mail Barcode Encoder In None Using Barcode drawer for Font Control to generate, create British Royal Mail 4-State Customer Barcode image in Font applications. www.OnBarcode.comIf [ -n "$DEBUG" ] then exec 5>&1 else exec 5> $LOGFILE fi echo "Some Text" >&5 Data Matrix 2d Barcode Scanner In VB.NET Using Barcode reader for .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comData Matrix ECC200 Maker In Java Using Barcode generation for Android Control to generate, create DataMatrix image in Android applications. www.OnBarcode.comBased on the value of the DEBUG variable, the code sends output from file descriptor 5 either to stdout or to a log file. Generating Data Matrix In Visual Basic .NET Using Barcode creator for .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications. www.OnBarcode.comEAN 13 Printer In None Using Barcode generator for Office Word Control to generate, create EAN13 image in Word applications. www.OnBarcode.comCHAPTER 9 DATA REDIRECTION
Create Code-39 In Visual Studio .NET Using Barcode creation for Reporting Service Control to generate, create Code 3/9 image in Reporting Service applications. www.OnBarcode.comDraw GS1 DataBar In Java Using Barcode printer for Java Control to generate, create GS1 RSS image in Java applications. www.OnBarcode.comWhen file access is complete, you should close the open file with the exec command, as shown here: Create PDF417 In Java Using Barcode maker for Java Control to generate, create PDF 417 image in Java applications. www.OnBarcode.comScanning Barcode In C# Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comexec 3>&- EAN13 Encoder In None Using Barcode printer for Microsoft Excel Control to generate, create GS1 - 13 image in Office Excel applications. www.OnBarcode.comRecognizing Data Matrix In VS .NET Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comThis keeps your code clean. In both bash and ksh you will receive a Bad file descriptor error if you attempt to access a file descriptor that hasn t been opened. There is no trouble with closing a file descriptor that is not already open. Barcode Scanner In Java Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications. www.OnBarcode.comPrinting Code 128 In .NET Framework Using Barcode printer for ASP.NET Control to generate, create Code 128 image in ASP.NET applications. www.OnBarcode.comDescriptor Access from the Shell
One other method of reading from and writing to an open file descriptor is to use the shell s built-in print and read commands. Only ksh has the print command, but both ksh and bash have read. Both of these built-in commands take the -u switch, which gives you the ability to specify the file descriptor you want to access. Once the file is open, you can output directly to or read directly from that specific descriptor using these built-in commands. Two methods can be used with the print command in ksh. The first of the two examples here is the redirection to a specific file descriptor, as already discussed. The second uses the -u switch with a single-digit file descriptor. These are equivalent commands and are available only in ksh. print "all your base are belong to us" >&3 print -u3 "Now is the time" For bash, the available command is very similar. You have access to only the redirection syntax, however, as the -u switch isn t supported. You also need to replace the print command with echo. echo "all your base are belong to us" >&3 Like the built-in print command, the read command can be used in two ways. The first of the following two examples specifies redirection to a file descriptor. The second uses the -u switch, like the print command in ksh. The main difference here is that both bash and ksh have this capability. read line <&3 read -u3 line
All of these examples assume the file has been opened for reading or writing as appropriate. When you try to access a file descriptor that has not been opened, you will receive an invalid file descriptor: Bad file descriptor error in bash and a bad file unit number [Bad file descriptor]: error in ksh.
|
|