Previous Thread
Next Thread
Print Thread
XCALL AMOS and COPY with Unix #15926 20 Dec 07 02:55 AM
Joined: Nov 2007
Posts: 69
J
Jack Rupert Offline OP
Member
OP Offline
Member
J
Joined: Nov 2007
Posts: 69
We are trying to copy a file within a program under AShell from the AMOS side to the Unix side (or vice-versa) using XCALl AMOS and the COPY command.

COPY FILNAM.BAS="/test/dsk3/001002/FILNAM.BAS"

This works from the period prompt, but using XCALL AMOS it strips the quote marks and gives an error, of course. How do we execute this? Or can we?

TEMP$="COPY FILNAM.BAS="+CHR(34)+"/test/dsk3/001002/FILNAM.BAS"+CHR(34)

XCALL AMOS,TEMP$

error

Re: XCALL AMOS and COPY with Unix #15927 20 Dec 07 03:51 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,945
Good question. The problem you are facing only occurs under UNIX (i.e. not Windows), and only when not using the AMOSRUNSBR option (e.g. SET AMOSRUNSBR or OPTIONS=AMOS_RUNSBR in the miame.ini). In such a case, the command (TEMP$) passed to AMOS.SBR is converted into the equivalent HOSTEX command "$ASHELL "+TEMP$, and like all HOSTEX commands, gets processed by the applicable UNIX shell command processor before execution. Virtually all UNIX shells will strip quotes (both single and double), which they interpret as being there for the purpose of shielding the contents from certain shell filtering operations.

Fortunately, there are several workarounds:

1. In general, if you know you are dealing with UNIX command lines, you can "escape" any troublesome characters by preceding them with a backslash, e.g.

Code
XCALL AMOS,"COPY filnam.bas=\""/test/dsk3/001002/filnam.bas\"""
In the above example, I used the Basic convention of encoding a literal double-quote character with a pair of them, so, along with the use of the backslash to "escape" the literal quote, you end up with the following, as seen by the UNIX command line processor:

COPY filnam.bas="/test3/dsk3/001002/filnam.bas"

which then results in the following being seen by A-Shell:

COPY filnam.bas="/test3/dsk3/001002/filnam.bas"

which is what you originally wanted.

2. If using XCALL AMOS to execute an A-Shell LIT or RUN command, you can force it to run as a true subroutine (rather than launching a child A-Shell process), either globally by using OPTIONS=AMOS_RUNSBR, or SET AMOSRUNSBR. Or, you can force it for just that XCALL by adding the pflag parameter set to 1, e.g.:

Code
XCALL AMOS,"COPY filnam.bas=\""/test/dsk3/001002/filnam.bas\""",0,1
That keeps the UNIX shell processor out of the picture and thus eliminates the special handling of quotes.

3. Since you are just copying a file, you could use MIAMEX, MX_COPYFILE which operates at the OS level and thus doesn't require any special handling of quotes, e.g.:

Code
xcall MIAMEX, MX_COPYFILE, "/test/dsk3/001002/filnam.bas", "./filnam.bas", CPYF_REPL, STATUS
4. You could also use XCALL HOSTEX, "cp ...", e.g.:

Code
xcall HOSTEX, "cp /test/dsk3/001002/filnam.bas ./filnam.bas"
Note that in this case, you might need to translate the AMOS spec into native form (using MIAMEX, MX_FSPEC). We avoided it in this example by assuming that the output file was in the current directory.


Warning: in all of the above, except method #2, you probably want to use lower case (i.e. filnam.bas rather than FILNAM.BAS), since A-Shell assumes lower case when converting AMOS filespecs to native. Upper case filenames will appear in DIR (because it scans the directory), but will appear to not exist when you try to open or otherwise access the file directly.

Re: XCALL AMOS and COPY with Unix #15928 20 Dec 07 06:56 AM
Joined: Nov 2007
Posts: 69
J
Jack Rupert Offline OP
Member
OP Offline
Member
J
Joined: Nov 2007
Posts: 69
Thank you for your enlightenment. I was able to work around using

XCALL MIAMEX,3 and then XCALL HOSTEX, "cp".

I am a bit rusty on the Unix and had forgotten the backslash (ESC). I think I like the MIAMEX,3 and then the HOSTEX better though as I can trap the status on each.

Nice to know you are there, Jack. Don't know if you remember me or not (Ja-Tech) from Michigan. I'm now with CompuPay in Florida after 15 years of semi-retirement. Still love INFLD/INMEMO and now I'm an AShell fan.

Re: XCALL AMOS and COPY with Unix #15929 20 Dec 07 07:07 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,945
FYI, you can trap the return status on the MIAMEX,27 (MX_COPYFILE) as well. In fact, it gives somewhat more helpful status codes for the typical errors, but in the end, it is implemented by executing the "cp" or "mv" commands, so amounts to about the same thing as your procedure.

Indeed, I remember meeting you about 15 years ago at a show, and we talked on the phone about some kind of INMEMO issue about 5 years ago. I'm glad to hear you got connected with CompuPay (a long-time A-Shell user/developer and very successful company).

Looking forward to hearing more from you on the BBS... I


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3