[Contact] [products] [corporate] [SERVICE] [useful & new] [contact MKS] [search tools] Toolkit - Questions & Answers Table of Contents * Renaming files in a Tar archived file * Examples using the Tar command * /dev/null and shell scripts on DOS and NT * Using cpio and redirect block information to standard output and a file * Useful function that you might find handy on DOS * Meaning of "glob exec error" * Meaning of "Temporary file error" * Attributes on MKS vi * Finding a Word in a Directory Tree * Moving the IRQs on the DOS UUCP software * Using pack to port file to MSDOS/WIN * HELP on forward slash (/) vs. backslash (\) using MKS kornshell (sh.exe) * Does TK work with NT 4.0 beta? * Technical Tips for finding Unsupported Software ---------------------------------------------------------------------------- An up-to-date technical specification file for all OS'es supported by Toolkit. Click here for a text-only spec sheet on Toolkit ---------------------------------------------------------------------------- Renaming files in a Tar archived file Here is an example of how to rename long files in a tar archive. The following tar archive was created on unix with long filenames that are not valid in DOS. The tar command does not have the capacity to rename files, however the pax command will read tar format file and does have the capactity to rename the output files. pax -rik < file ---------------------------------------------------------------------------- Examples using the Tar command To tar entire harddrive into a file: tar -cvf c:\test.tar To tar a directory into a file: tar -cvf c:\test.tar c:\etc To view a tar file: tar -tvf test.tar To untar (extract) a tar file: tar -xvf test.tar To tar into multi-volume (floppies) tar -cv -V a:Volume# c:\etc To untar from multi-volume (floppies) tar -xv -V a:Volume# c:\etc To tar entire harddrive into tape: tar -cv /dev/mt0 To tar directory into tape: tar -cv /dev/mt0 c:\etc ---------------------------------------------------------------------------- /dev/null and shell scripts on DOS and NT Unix, DOS and NT provide a special null device that will consume input. This is useful in many shell scripts. Unfortunately the name of this device is different on DOS/NT than on Unix. The follow script offers a suggestion on how to handle the problem in a portable fashion. #!/bin/sh SYS=$(uname) case "$SYS" in DOS|*NT) DEVNULL=nul ;; *) DEVNULL=/dev/null ;; esac echo "This doesn't show up on the screen" > $DEVNULL ---------------------------------------------------------------------------- Using cpio and redirect block information to standard output and a file find . -print | cpio -ovcO output_filename 2>&1 | tee log.txt ---------------------------------------------------------------------------- Usefule function that you might find handy on DOS # name this file function.ksh and adds this to your profile.ksh by # typing ". function.ksh" # makes file completion accept filename as well function cd { case $1 in *[!:]/) command cd ${1%/};; *) command cd $1;; esac } #Type 'dh' will gives DOS HELP function dh { BKPATH=$PATH PATH=c:/dos c:/dos/help $1 PATH=$BKPATH unset BKPATH } #Type 'th' will gives MKS HELP function th { BKPATH=$PATH PATH=c:/bin c:/bin/help $1 PATH=$BKPATH unset BKPATH } ---------------------------------------------------------------------------- Meaning of "glob exec error" The cause of the message is that the DOS program can not run the glob.exe program used to expand wildcard problems. Go to your autoexec.bat file and add "set GLOB=c:\etc\glob.exe" (or to point to where you have your etc directory stored). ---------------------------------------------------------------------------- Meaning of "Temporary file error" When running 'vi', this includes both of the Windows 'vi' icons and running 'vi' from DOS. All of the sudden, when trying to run vi either from DOS or using the Launch frontend, (regardless of whether I provide an argument or not), it gives the following error: "Temporary file error" no such file or directory and the program ends without entering screen mode. Solution: It turns out that all of my environmental variables, including TMPDIR, were set up correctly. BUT, all of the directories assigned to any of my "TEMP" type variables were pointing to a drive that was too close to being full. After a disk cleanup and a defragmentation, vi was as good as new. ---------------------------------------------------------------------------- Does TK work with NT 4.0 beta? NT 4.0 is tested on TK 5.1 but not supported yet. The test suite runs fine with 2 minor exception. It will be supported when the final version of NT 4.0 is released by producing either a letter release or a number release from the MKS TK that supports it. The 2 minor exception is: On installation, the target fields in the shortcuts for "shell" and "mks information" contain quotes around the path name and one cannot start these files. To workaround the problem, edit the Properties of these 2 shortcuts and remove the quotes. ---------------------------------------------------------------------------- Attributes on MKS Vi The attrib settings in MKS VI allows you to set the colours used in Vi. The value is or'ed into the video attribute memory associated with each character on the PC screen. Here are Some Common Adaptor Settings. 0x0700 -- black and white 0x1700 -- blue and white 0x7000 -- inverse video Here are samples setting for a VGA Adaptor. Here are some of the attribute bit settings for VGA displays. Bit 14 (0x4000) is for background Red Bit 13 (0x2000) is for background Green Bit 12 (0x1000) is for background Blue Bit 10 (0x0400) is for foreground Red Bit 9 (0x0200) is for foreground Green Bit 8 (0x0100) is for foreground Blue Bit 15 (0x8000) is for foreground blinking Bit 11 (0x0800) is for foreground intensity 0x0200 is green on black 0x0700 is white on black 0x7000 is black on white ---------------------------------------------------------------------------- Finding a Word in a Directory Tree To find a word in a file in the directory tree, use the following command: grep word $(find c:/ -name "*.c") where word is (word to search for) c:/ is (directory to start searching) *.c is (type of files to search for) ---------------------------------------------------------------------------- Moving the IRQs on the DOS UUCP software The DOS UUCP software has three advanced settings you can use to control the interrupt setup with, enable port, enable mask and vector. Here is how you would setup a port at IRQ5: Interrupt enable port; this is 21 for interrupts 0-7, and A1 for interrupts 8-F. Therefore, this should be 21. Interrupt enable mask; this the bit to be masked out on the interrupt enable port, in order to enable the appropriate interrupt. The bit assignments are like this: Bit Mask Interrupt -------------------------- 7 80 Interrupt 7 (Typically the printer) 6 40 Interrupt 6 5 20 Interrupt 5 <--- This is the one we want, IRQ5 4 10 Interrupt 4 (Typically COM1) 3 8 Interrupt 3 (Typically COM2) 2 4 Interrupt 2 (Multiplexed for Interrupts 8-F) 1 2 Interrupt 1 (The keyboard) 0 1 Interrupt 0 (The system timer) Therefore you want Mask 20. The interrupt vectors on the PC are 08+IRQ for IRQ0-IRQ7. Therefore, you want an Interrupt Vector of 0D. In summary: IRQ3 IRQ4 IRQ5 Interrupt enable port: 21 21 21 Interrupt enable mask: 08 10 20 Interrupt vector: 0B 0C 0D Therefore you want, 21, 20, 0D. ---------------------------------------------------------------------------- Using pack to port file to MSDOS/WIN MKS Toolkit offers commands (awk, ex, sh, pack, unpack, sed, ...) that is similar to Unix. MKS pack/unpack is fully compatible with Unix pack/unpack version. Unix pack uses Huffman Code compression method. One can pack a file by using the following steps: 1) Scan the file and built a table according to the number of occurences of each byte value (ie. c=0 to c=255) 2) This table is used to create a tree which uses the shortest code when decoding (tranverse from the root to the node representing the character) for the bytes which occur most often. As an example, if more than 50% of the bytes in a file consists of space character. Then the space character could be coded as a single bit "0". All other byte values would start with bit "1". 3) The number of bytes in the original file are written as a long tree. 4) The tree is then written back to the output file as a series of bits and the data is written to the file. 5) The data is then output as a series of bits. To unpack the file: 1) Read in the length of file 2) A table is created 3) The table will read the rest of the file It might not be a good idea to use pack.exe if the file is short since the table is being stored with the file. ---------------------------------------------------------------------------- HELP on forward slash (/) vs. backslash (\) using MKS kornshell (sh.exe) For starters, use 'print -r -- "$PATH"'. This will display your PATH without character expansions/translations from sh or echo. Next step is to translate the offending charaters. This may be done like this: PATH="$(print -r -- "$PATH" | tr \\ /)" Commands such as awk and sed may be substituted for tr. If you want to stick to the shell so that your program is not going to disk to exec tr (awk, sed, etc.), try this: easy_tr(){ in="$1" # $1 is the pattern to replace out="$2" # $2 is the replacement shift 2 string="$*" # $3-$# are the strings to translate result="" right="${string#*$in}" while [ "$string" != "$right" ] ; do result="$result${string%$in$right}$out" string="$right" right="${string#*$in}" done print -r -- "$result$string" } PATH="$(easy_tr \\ / "$PATH") ---------------------------------------------------------------------------- Technical Tips for finding Unsupported Software For Unix-like shells and utils, try: NT Resource Kit - buy it, or FTP from: ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/ Ports of GNU utils - ftp://ftp.cygnus.com/pub/sac/ (recent), or CICA and/or SimTel (older ports) Hamilton C Shell - EMail hamilton@bix.com for free demo Tcl/Tk for NT is available from: ftp://ftp.smli.com/pub/tcl/ JO's Sun release (Alph a #1) ftp://mm-ftp.cs.berkeley.edu/pub/multimedia/winnt X/Motif: Several commercial products (e.g., Hummingbird's eXceed/NT, ...). NFS: Several commercial products (e.g. Sun/Intergraph's PC/NFS, B&W, ...) ---------------------------------------------------------------------------- This list is by no means complete and we are continuing to look for more questions to place on here. If you have any suggestions, please mail them to us. ---------------------------------------------------------------------------- Last Modified: $Date: 1996/05/02 11:30:25 $: EDT. © 1996 Mortice Kern Systems Inc. All Rights Reserved. External sites are not endorsed by MKS. .