Passive Shell Commands

Monte Goulding monte at
Tue Oct 8 22:57:42 EDT 2013

On 09/10/2013, at 1:45 PM, Ray Horsley wrote:

> First time using open process for me.  Fascinating!  Thanks Monte. Not quite sure on the write and read syntax.
> My original shell command which works fine is:
>   get shell(""&appPath&" "&srcPath&" "&trgPath&"")
> where the app is a command line utility which converts a PDF file to multiple JPEG's
> I can't get the app to show up in 'the openProcess' using the 'neither' option.  When I call 'open process appPath for update' it works fine, but then how would I send the open process a command to start the conversion?

Ah, I assumed you didn't need to read from the process. If you don't need to read or know when it's done then:
open process appPath&" "&srcPath&" "&trgPath for neither

If you need to know when it's done then something like this should do it (untested hacking in email client)

put appPath&" "&srcPath&" "&trgPath into tProcess
open process tProcess for read
send "ReadProcess tProcess" to me in 0 milliseconds

on ReadProcess pProcess
  local tOut
     read from process pProcess in 5 milliseconds
     put it after tOut
     wait 20 milliseconds with messages
     if the result is "eof" then
        close process pProcess
        exit repeat
     end if
  end repeat
  PDFExported tOut
end ReadProcess

on PDFExported pOutput
  -- let the user know
end PDFExported

M E R Goulding 
Software development services
Bespoke application development for vertical markets

mergExt - There's an external for that!

More information about the Use-livecode mailing list