AmigaDOS script problem.
23/09/2017 12:57
Many years ago I wrote several AmigaDOS scripts to solve differentproblems, however it was a long time ago, and now I have beenwriting alot of sh-scripts (in UNIX that is) at work, and whenI tried to write an AmigaDOS script I ran into several problems,some of them I solved with the help of my 3.1 DOS manual, andsome of them just needed some refresh of my memory (like thedifferent handling of variables) but some other I haven't solved yet..

First of all, if I want the output from one command into avariable, is that possible ? ..I mean like foo=`ls -Fla /etc/passwd` in sh.. if I do this (in UNIX) the variable $foo (<foo> in AmigaDOS)would contain the output of the command within `` like: bash-2.03$ foo=`ls -Fla /etc/passwd` bash-2.03$ echo $foo -rw-r--r-- 1 root sys 458 Jul 15 23:47 /etc/passwd bash-2.03$ Now I have solved it with tempfiles, wich is not very neat, especiallywhen you want to run several instances of the same script.

..Next problem.

I have a part that do: IF <unit> EQ dh0: ..and then the actions that should be taken, however I then need tohave one IF part (around 30 rows) for each partition (18) wichmake the script very long..

I would rather have it something like IF <unit> EQ dh0: OR dh1: OR <dh2: and so on..

I would GUESS that this should be done with the | , but this isnt verygood documented, and I didnt get it to work..

For example: IF <unit> EQ dh0:|dh1:|dh2: ..How is the correct way to do this ? ..Apart from that the Amiga shellscripting feels pretty modern regardingto its age.. the main think I miss from the unixworld is that there allprograms is pipe-aware.. so you can easilly do something like: bash-2.03$ grep glenn /etc/passwd | cut -d: -f3 1001 bash-2.03$ get the UID (field 3) in the passwd for the user glenn.. surethe Amiga also have the pipe ability, but you can't normally pipe stuff into the commands, wich makes it not so useful.

I also is a bit irritated on that variables uses <var>, and > isused for redirection.. gah.. sure .bra .ket solves this, but it'sstill a very stupid way, I would like to have $var instead.

Source is Usenet: comp.sys.amiga.misc
Sign in to add a comment

Answer score: 5
23/09/2017 12:57 - Hi, Yes, though backticks do not work consistently up to 3.9.1. Fixed inBB2 of Os 3.9, and another bug-fix patch found on Aminet. (Sigh) Not possible with a plain if.

Filter the output thru a text parser that can check for equality bypattern matching. IIRC, SED could do that. (On Aminet).

It's not. Shell scripting has several severe flaws, one of them being theun-ability to branch freely and to create subroutines. This is mainly causedby the simple-minded way how shell scripts work and/or how the shellparses them.

IIRC, some implementations of the PIPE command support special pseudo devicesnamed IN: and OUT: that define the reading or writing end of the pipeto allow redirection for commands that expect a file name rather thanpresenting results on STDOUT.

Shell variables *are* indicated by $var, and/or by ${var}. What you havehere is just a pre-processor token that gets replaced by the macro parsernamed the Execute command. These aren't variables. Execute does a blindcopy/paste and inserts the command line tokens into the source file bycreating a temporary shell script in T: which is then executed by the shell.

So long, Thomas

Source is Usenet: comp.sys.amiga.misc
Sign in to add a comment

Answer score: 5
23/09/2017 12:57 - +Thomas Richter <> wrote Unfortunatly I still use AmigaOS 3.1 (ROM 3.0) on this machine :/ Ok, so there is no real way to do this with if.. :( But you have to remember that the shellscripting as we see it today wasintroduced with Workbench 2.0, and existed even earlier.. still Ithink it feels pretty ok, even if it ofcoz is beaten by the unix sh-scripting.

(or your fauvorite shell..) Ah, this could be a way to solve it, but its not a part of the standard OSI guess.. ? Well, I would call them variables anyway, in a shellscript.. it's adifference between the shell and a shellscript here.. (wich isnot the case in an unix environment..)

Source is Usenet: comp.sys.amiga.misc
Sign in to add a comment

Helpforce eDiscover provides technical articles updated each dayHelpforce eDiscover RSS feed contains the latest technical articles in RSS
Click the logo to go back to the main page
Search eDiscover

Click an icon to go to that category

Helpforce eDiscover contains articles about Microsoft Windows Helpforce eDiscover contains articles about Apple products and MacOS Helpforce eDiscover contains articles about Linux and POSIX operating systems Helpforce eDiscover contains articles about Helpforce Helpforce has a large variety of technical information and articles for you to read Helpforce eDiscover contains articles about databases, MYSQL, SQL Server Oracle Helpforce eDiscover contains articles about Java, JVM and the JRE Helpforce eDiscover contains articles about the QNX operating system Helpforce eDiscover contains articles about Oracle Solaris and Open Solaris Helpforce eDiscover contains articles about RISC OS, Acorn and the BBC Micro Helpforce eDiscover contains articles about Amiga and AmigaOS

Type your comment into the box below