Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!rochester!pt!spice.cs.cmu.edu!mjp From: mjp@spice.cs.cmu.edu (Michael Portuesi) Newsgroups: comp.sys.amiga Subject: AmigaDOS script hacking: flames Message-ID: <1249@spice.cs.cmu.edu> Date: Thu, 30-Jul-87 18:20:23 EDT Article-I.D.: spice.1249 Posted: Thu Jul 30 18:20:23 1987 Date-Received: Sat, 1-Aug-87 11:04:02 EDT Reply-To: mjp@spice.cs.cmu.edu (Michael Portuesi) Organization: Carnegie-Mellon University, CS/RI Lines: 54 Keywords: I decided to experiment with AmigaDOS script-hacking, just to see how far I could push it. Often, I download software from Usenet or other places in big batches and place it in subdirectories on a disk. It would be nice if I could run a command from the root directory on every file that matched a pattern anywhere on disk, much like the ALL keyword for COPY and DELETE. This way, I could un-shar every .sh file on a disk with just one command, e.g. EXECUTE apply "shar -u $name" #?.sh Armed with the AmigaDOS manual, I began my task. Realizing that AmigaDOS does not allow iteration over the results of a command, like the "foreach" statement in csh, I opted to direct the output of DIR to a file and run it through EDIT to create a file of executable commands that I would EXECUTE. DIR, while offering an option to do a recursive directory list, also outputs its information in a two-column format that is impossible to parse with EDIT. LIST, while offering a listing that is easily interpreted by other programs, does not offer a recursive directory search. Grrr. So I decided to use DIR to list just the subdirectories of the current directory to a file. Then I would run that through EDIT to create a batch of LIST commands that would generate all the file names, plus instructions to concatenate those into one big file. This file would be run through EDIT once again to create the executable commands, and then executed. It is easy to run EDIT in batch mode. It is easy to use ECHO to create a command file for EDIT. But when the necessary commands for EDIT exceed one line, you're hosed because ECHO can only handle one line of input, and AmigaDOS doesn't know how to redirect output by appending to the end of a file! So what have I learned from this? 1) The CLI and the EXECUTE command are unsuitable for general-purpose shell hacking. 2) The AmigaDOS commands weren't written with batch processing of any type in mind. 3) Not only is EDIT a lose as an interactive line editor, it is also a very bad stream editor. 4) I'll try this again with Matt's Shell at the earliest opportunity. -- Mike Portuesi / Carnegie-Mellon University Computer Science Department ARPA: mjp@spice.cs.cmu.edu UUCP: {backbone-site}!spice.cs.cmu.edu!mjp BITNET: rainwalker@drycas (a uVax-1 run by CMU Computer Club...tons o' fun) "Paradise is exactly like where you are right now...only much, much better" --Laurie Anderson, "Lanugage is a Virus"