From: | Nick Clover |
Date: | 20 Jun 2001 at 22:31:50 |
Subject: | Re: Running external programs |
Hello Steve
On 20-Jun-01, you wrote:
> Hello again,
> OK, I'm putting the finishing touches to a little (?!?) utility, which as a
> matter of course hasto run external programs (either my own, or AmigaDOS
> commands).
> 1) I've tried it two ways, opening an ARexx port and having the orig program
> generate and run an Arexx script - Very clunky and untidy.
> 2) Writing a commandline to CON: and using the Execute_ command.
> Option two is much cleaner and faster, but opens a CON: window on screen. I'd
> like to acheive the same effect, but without the CON: window, but I'm stumped.
> I need to be able to run an external program, and then, as I wish, either
> continue executing the original program immediately, or optionally, wait for the
> external program to return before continuing. I don't want to use any third
> party hacks because I want my program to run on as wide a range of machines as
> possible, without the need to install anything other than mine.
> Do I have any options?
> All the best
I have written several programs that run externals without a CON: window, I use the
following method
cmd$="external program"
execute_ &cmd$,0,0
you will still get a CON: on anything less than OS3.x
If the program you are waiting to finish is your own just get it to
write a tempory file in t: then use a loop to check for it eg.
External program:
if writefile(0,"t:return")
fileoutput 0
nprint "finished"
defaultoutput
closefile 0
else
;oops an error
endif
Main Program:
finished.b=false
repeat
filefound.l=lock_("T:return",0)
if filefound
finished.b=true
unlock_ filefound
kill "T:return"
endif
delay_ 1
until finished
If it's not yours try executing two commands at once eg.
cmd$="external program"+chr$($A)+"Echo >T:return finnished"
Then use the same routine to check for it, I'm not sure this
will work as I havn't tried it...
Hope this helps...
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie