Batch files: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 12: | Line 12: | ||
The commands are formatted exactly as they would be from the command line and a carriage return signals that the next line should be processed as the next command in the sequence. | The commands are formatted exactly as they would be from the command line and a carriage return signals that the next line should be processed as the next command in the sequence. | ||
In IBM terminology and therefore in most IBM publications batch | In IBM terminology and therefore in most IBM publications batch file commands on OS/2 are referred to as ''Command Language'' which might seem confusing for some readers, this is a vestige from mainframes and minicomputer system where batch files actually came to have something resembling a language, however nothing similar was ever ported or created for OS/2 as IBM was slowly replacing those constructs with [[REXX]]. | ||
==OS/2 Batch file commands== | ==OS/2 Batch file commands== |
Revision as of 16:18, 7 July 2016
Batch files are text files that are used to execute system commands in sequence. Those include all commands you can use from a command shell, any external program that is in the path or that you specifically point to in a location outside of the path, in addition to small number of commands that are either specific to batch files and do not function inside the command line shell or commands that will function but are not meaningful in normal command line usage.
The OS/2 system natively runs OS/2 batch files that have the the file extension CMD and if you have the DOS subsystem installed and activated the system also runs any DOS batch file, which in turn have the extension BAT. If you do not have the DOS subsystem installed on your system you can also run DOS batch files from an emulator such as DOSBox, but you will lose all the nifty integration features that the OS/2 DOS subsystem has to offer. DOS and OS/2 batch files are for the most part identical except for the fact that the CMD files run inside an OS/2 Command shell and the BAT files inside a DOS Command shell, and if you have the DOS subsystem installed you can call OS/2 programs from DOS batch files and DOS programs from OS/2 batch files.
In addition you can install a number of alternate command line interfaces that either allow you to expand the number of available batch file commands or run completely different types of batch files. Most third party command shells have some sort of batch file functionality built in and some have full scripting languages, the 4OS/2 and 4DOS replacement shells have an batch language very similar to the OS/2-DOS language but with extensions, the 4OS/2 and 4DOS batch files use the BTM file extension. Shells ported from the UNIX world will allow you to run classic sh shell scripts, which are more feature rich than OS/2 style batch files but not quite as powerful as REXX scripts.
While the DOS market saw a huge number of utility programs released that allowed you to extend the functionality of batch files there was never such a market for batch extenders for OS/2 although a few popped up. This is mainly due to the presence of REXX as a component of the OS, but since that is a fully fledged programing language, albeit one that is unusually easy to use, you can in most cases literally create the functions you might want from REXX in less time than it would take you to trace down a third party utility on the net.
- File format
The Batch file format is as simple as it gets, no matter if it is a DOS, 4DOS, an OS/2 or 4OS/2 batch file it is always an 8 bit plain text file that adheres to the charset that the system codepage allows at any given time. You can create or edit the file with any text editor or word processor that allows you to open and save plain text files, which is just about all of them, if you want the file in another codepage than the system is currently running simply assign another codepage to the program object properties if you run it from the PM, or issue a CHCP XXXx command at the beginning of the file, which is limited to 2 different codepages by adjustments of COUNTRY setting in CONFIG.SYS.
The commands are formatted exactly as they would be from the command line and a carriage return signals that the next line should be processed as the next command in the sequence.
In IBM terminology and therefore in most IBM publications batch file commands on OS/2 are referred to as Command Language which might seem confusing for some readers, this is a vestige from mainframes and minicomputer system where batch files actually came to have something resembling a language, however nothing similar was ever ported or created for OS/2 as IBM was slowly replacing those constructs with REXX.
OS/2 Batch file commands
- CALL
- ECHO
- ENDLOCAL
- EXTPROC
- FOR
- GOTO
- IF
- PAUSE
- REM
- SETLOCAL
- SHIFT
In addition the above commands a batch script can call any valid OS/2 program including normal executables, scripts in other languages and system commands. Most batch commands have formatting and options more like a executable than what you would expect from a scripting language. Some batch file commands can also be used from the command line but have limited utility there.
- OS/2 text & programmers editors with OS/2 batch file support
- Boxer - Support built in
- FTE - Has support for syntax highlighting, code folding and syntax-aware autoindent. - Open source - Current.
- DOS text & programmers editors with OS/2 batch file support
- Boxer - Support built in
- FTE - Has support for syntax highlighting, code folding and syntax-aware autoindent. - Open source - Current.
DOS Batch file commands
- @
- %?
- %?%
- CALL
- ECHO
- FOR
- GOTO
- IF
- PAUSE
- REM
- SET
- SHIFT
- OS/2 text & programmers editors with DOS batch file support
- Boxer - Support built in
- FTE - Has support for syntax highlighting, code folding and syntax-aware autoindent. - Open source - Current.
- jEdit - Java based editor - DOS Batch file syntax highlighting built in - Current.
- DOS text & programmers editors with DOS batch file support
- Boxer - Support built in
- FTE - Has support for syntax highlighting, code folding and syntax-aware autoindent. - Open source - Current.
Publications
English
- Busch: Supercharging OS/2 : Batch Files and Utilities – Addison-Wesley 1988, ISBN 0-201-13785-2
- Richardson: MS-DOS Batch File Programming Including OS/2 – TAB Books 1988, ISBN 0-8306-2928-9
- Ronny Richardson: MS-DOS Batch File Programming - Fourth Edition - June 1993 - Windcrest/McGraw-Hill - Hardcover, 405 pages + examples on a floppy disk - ISBN 0830645888 - ISBN 978-0830645886 - Out of print.
- Updated edition of the above book but misses some OS/2 1.x content.
- Ronny Richardson: MS DOS Utility Programs: Add-On Software Resources - 1989 - Windcrest - Hardcover, 665 pages - ISBN 0830692789 - ISBN 978-0830692781 - Out of print.
- Ronny Richardson: MS-DOS Batch File Utilities - October 1991 - Windcrest - Hardcover, 372 pages + examples on a floppy disk - ISBN 0830624821 - ISBN 978-0830624829 - Out of print.
- Appears to be an updated version of the above book, even though it is not noted as such on the cover
- Ronny Richardson: Batch Files To Go: A Programmer’s Library - March 1992 - Windcrest - Hardcover, 336 pages + examples on a floppy disk - ISBN 0830639896 - ISBN 978-0830639892 - Out of print
- Ronny Richardson: OS/2 Batch Files to Go – McGraw-Hill 1994, ISBN 0-07-052369-X - Reprint of the book below
- Ronny Richardson: OS/2 batch files to go - 1994 - Windcrest/McGraw-Hill - Paperback, 348 pages - ISBN 0830645896 - ISBN 978-0830645893 - Out of print
- This appears to be an "OS/2ified" version of the DOS title "Batch Files To Go: A Programmer’s Library".
- Ronny Richardson: The Ultimate Batch File Book! - McGraw-Hill - June 1995 - Paperback, 448 pages + CD-ROM - ISBN 0079120512 - ISBN 978-0079120519 - Out of print.
- Has OS/2 and Win95 information in addition to DOS batch files.
- Ronny Richardson: Writing DR DOS Batch Files - January, 1993 - Windcrest - Paperback, 432 pages - ISBN 0830642447 - ISBN 978-0830642441 - Out of print
- Kris Jamsa: MS-DOS Batch Files: Microsoft Quick Reference - January 25th, 1990 - Microsoft Press - Paperback, 176 pages - ISBN 1556152353 - ISBN 978-1556152351 - Out of print.
- Kris Jamsa: MS-DOS Batch Files: Second edition - 1991 - Microsoft Press - Paperback, 176 pages - ISBN 1556153384 - ISBN 978-1556153389 - Out of print.
- Kris Jamsa: Concise Guide to Microsoft DOS Batch Files; Third revised edition - June 1993 - Microsoft Press - Paperback, 220 pages - ISBN 1556155492
ISBN 978-1556155499 - Out of print.
- Kris Jamsa: Concise Guide to Microsoft DOS Batch Files; Revised edition - December 1993 - Penguin Books - Paperback, 224 pages - ISBN 1556156383 - ISBN 978-1556156380 - Out of print.
- Ronny Richardson: Builder Lite: Developing Dynamic Batch Files - January 1993 - Windcrest - Hardcover, 304 pages + examples on a floppy disk - ISBN 0830641750 - ISBN 978-0830641758 - Out of print
- Discusses building Batch files with Builder/Builder Lite, a shareware batch file compiler
- Ronny Richardson: Dr. Batch File's Ultimate Collection - November 1992 - Windcrest - Paperback, 448 pages + examples on a floppy disk - ISBN 0830641130 - ISBN 978-0830641130 - Out of print
- More of a listing and explanation of about 120 utilitarian batch files included on floppy than a tutorial per se.
Turkish
- Haluk Polat: Toplu Ýş Dosyalari: Kolay Býlgý Kilavuzu - Mixed text/HTML file via Archive.org - 1997
- Tutorial on how to use DOS and OS/2 batch files in Turkish, please note that the page uses the Turkish 8859-9 code page without correctly declaring it in the header and will render incorrectly on modern browsers.
Links
- Roger Orr: Extending OS/2 Batch Files - Uses very simple REXX files as an example
- JaTomes OS/2 Batch file commands - Fairly exhaustive
- Rob van der Woude's Scripting site - Has lots of info