Re: shell() in a separate thread with callback message at exit?

2007-03-12 Thread Joel Guillod

Here is an example script that does a ping. The handler includes the
post-processing of the result, but you can just ignore that.

function checkPing pIP
...
   put ping -c1 -npIP into tShellCmd
   put tFileName   21  after tShellCmd


Thank you a lot Sarah. Your code let me discover the wait .. with  
messages which I have never been aware of (the old Hypercard  
practice?). This can actually do the job I am searching for. Also,  
your example raises two questions:


1.- Is there somewhere some documentation on synchronous/asynchronos  
parallel/threaded Transcript execution? I would like to learn about  
other such great features native in Transcript...


2.- I understand the shell command you wrote up to ping -c1 -n  
192.168.0.1 and even the  mandatory for executing the shell in a  
separate thread but I dont understand the 21 . Could you  
explain? Do you have a good MacOSX/Un*x tutorial on the shell commands?


Best to you,

Joël___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: shell() in a separate thread with callback message at exit?

2007-03-11 Thread David Bovill

This is an important feature request - no?

I am not sure how to do this - I have suspected you may be able to do this
with some clever shell scripting - but not cracked it for things that you
need results from. You can put a shell into the background using  ie
think, and you could look into the screen command, but the only ways I
figured on doing this properly is to have a separate program running and
executing the shell. This program can then talk to Rev using sockets or some
other technique.

On 10/03/07, Joel Guillod [EMAIL PROTECTED] wrote:


 What platforms are you supporting?

 If it is Mac only then I think you can achieve this using an
 AppleScript and AppleEvents.

 Let me know and I'll let you have more details.

Yes, I would be very pleased to get the details for MacOSX. Also I
need to support this feature under Windows but let us start with the
Mac solution.

Thanks a lot,
Joel


 All the Best
 Dave

 On 8 Mar 2007, at 11:20, Joel Guillod wrote:

 How can I implement the following features:

 - invoque a shell command in a separate thread, i.e. a non
 blocking shell during execution of the command;
 - receive a callback message with the output and the error result
 when the thread exits?

 This would be some function similar to the load command, i.e.:

shellExecute commandLine [with message callbackMessage]

 where ...

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: shell() in a separate thread with callback message at exit?

2007-03-11 Thread Sarah Reichelt

On 3/8/07, Joel Guillod [EMAIL PROTECTED] wrote:

How can I implement the following features:

- invoque a shell command in a separate thread, i.e. a non blocking
shell during execution of the command;
- receive a callback message with the output and the error result
when the thread exits?

This would be some function similar to the load command, i.e.:

shellExecute commandLine [with message callbackMessage]

where
   The commandLine is a string or an expression that evaluates to a
string.
   The callbackMessage is the name of a message to send after the
shell exited.

The callbackMessage signature would be:

   on callbackMessage pCmdOutput,pCmdError,pShellError

where
   - pCmdOutput is the value returned by the shell function, i.e. the
result of the sdtout commandLine, including any error messages the
commandLine generates.
   - pCmdError is the error the command generate (sdterr under unix).
   - pShellError is the shell command's exit code.



Hi Joel,

This isn't exactly what you described, but here is how I do it. Start
the shell command running in the background but directing it's output
to a text file. Then have a loop to check for this text file until it
appears or until a time out period has elapsed.

Here is an example script that does a ping. The handler includes the
post-processing of the result, but you can just ignore that.

function checkPing pIP
   put specialFolderPath(Desktop)  /ping.txt into tFileName
   if there is a file tFileName then delete file tFileName

   put ping -c1 -npIP into tShellCmd
   put tFileName   21  after tShellCmd
   get shell(tShellCmd)

   put 0 into timeCheck
   repeat 50 times
   wait 1 tick with messages
   if there is a file tFileName then
   put URL (file:  tFileName) into tRes
   if tRes is empty then next repeat  -- file created but no result yet

   put wordOffset(loss, tRes) into tWord
   if tWord = 0 then next repeat -- file created but result
not complete

put word tWord-2 of tRes into tPercent
   if tPercent = 0% then return true
   else return false
   end if
   end repeat

   if there is a file tFileName then delete file tFileName
   return false
end checkPing

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: shell() in a separate thread with callback message at exit?

2007-03-10 Thread Joel Guillod

What platforms are you supporting?

If it is Mac only then I think you can achieve this using an  
AppleScript and AppleEvents.


Let me know and I'll let you have more details.


Yes, I would be very pleased to get the details for MacOSX. Also I  
need to support this feature under Windows but let us start with the  
Mac solution.


Thanks a lot,
Joel



All the Best
Dave

On 8 Mar 2007, at 11:20, Joel Guillod wrote:


How can I implement the following features:

- invoque a shell command in a separate thread, i.e. a non  
blocking shell during execution of the command;
- receive a callback message with the output and the error result  
when the thread exits?


This would be some function similar to the load command, i.e.:

   shellExecute commandLine [with message callbackMessage]

where ...


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


shell() in a separate thread with callback message at exit?

2007-03-08 Thread Joel Guillod

How can I implement the following features:

- invoque a shell command in a separate thread, i.e. a non blocking  
shell during execution of the command;
- receive a callback message with the output and the error result  
when the thread exits?


This would be some function similar to the load command, i.e.:

   shellExecute commandLine [with message callbackMessage]

where
  The commandLine is a string or an expression that evaluates to a  
string.
  The callbackMessage is the name of a message to send after the  
shell exited.


The callbackMessage signature would be:

  on callbackMessage pCmdOutput,pCmdError,pShellError

where
  - pCmdOutput is the value returned by the shell function, i.e. the  
result of the sdtout commandLine, including any error messages the  
commandLine generates.

  - pCmdError is the error the command generate (sdterr under unix).
  - pShellError is the shell command's exit code.


If I remember well the externals API allows for such threading and  
callback but I am not a C expert. Could anyone give me refs/pointers  
to a solution? I need a multiplatform solution.


Thanks a lot !  Joël


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: shell() in a separate thread with callback message at exit?

2007-03-08 Thread Dave

Hi,

What platforms are you supporting?

If it is Mac only then I think you can achieve this using an  
AppleScript and AppleEvents.


Let me know and I'll let you have more details.

All the Best
Dave

On 8 Mar 2007, at 11:20, Joel Guillod wrote:


How can I implement the following features:

- invoque a shell command in a separate thread, i.e. a non blocking  
shell during execution of the command;
- receive a callback message with the output and the error result  
when the thread exits?


This would be some function similar to the load command, i.e.:

   shellExecute commandLine [with message callbackMessage]

where
  The commandLine is a string or an expression that evaluates to a  
string.
  The callbackMessage is the name of a message to send after the  
shell exited.


The callbackMessage signature would be:

  on callbackMessage pCmdOutput,pCmdError,pShellError

where
  - pCmdOutput is the value returned by the shell function, i.e.  
the result of the sdtout commandLine, including any error messages  
the commandLine generates.

  - pCmdError is the error the command generate (sdterr under unix).
  - pShellError is the shell command's exit code.


If I remember well the externals API allows for such threading and  
callback but I am not a C expert. Could anyone give me refs/ 
pointers to a solution? I need a multiplatform solution.


Thanks a lot !  Joël


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution