Hi,

"OS" is a system module (although pre-imported in the Emacs OPI) and
as such is "sited". See
http://www.mozart-oz.org/documentation/dstutorial/node2.html#sited.entities
for an explanation.

Basically, you are trying to use a system module instance of machine A
on machine B which is forbidden (it's not really well-defined, if you
think about it).

One solution is to define a functor which explicitly specifies the
needed resources (like system modules) and "apply" that functor
remotely.
This is described here
http://www.mozart-oz.org/documentation/dstutorial/node3.html#label176
An extended example: http://rosettacode.org/wiki/Distributed_programming#Oz

Another possibility (closer to your original example) is to distribute
a port instead of a function. In this way you can make sure that
"OS.system" is executed on the correct machine.

Machine A:
declare P T in
thread
   Stream
in
   P = {Port.new ?Stream}
   for Command#Result in Stream do
      Result = {OS.system Command}
   end
end

{Connection.offerUnlimited P T}
{Show T}  % cut-and-paste this output into the following


Machine B:
local P Result in
  P = {Connection.take 'oz-ticket://...'} % copy ticket here
   Result = {Port.sendRecv P "ls /a/path"}
   {Inspect Result}
end


Let me make clear that this is only necessary because of the use of a
"sited" system modules. If you have a procedure that only uses
"unsited" modules, your original approach (distributing the procedure
itself) would be perfectly OK.

Cheers,
  Wolfgang

On Tue, Aug 3, 2010 at 9:51 PM, HP Wei <[email protected]> wrote:
>
> machines: Sun-sparcs,  mozart-oz version 1.3.2
>
> --------------------------------------------------
>
> On a remote machine A:
>
> declare F T in
>   proc {F}
>      {OS.system "ls /a/path"}
>   end
>
> {Connection.offerUnlimited F T}
> {Show T}  % cut-and-paste this output into the following
>
> ------------------------------------
>
> On another machine B:
>
> local F in
>   F = {Connection.take "x-ozticket:..."} % copy ticket here
>   {F}
> end
>
> -------------------------------------------
>
> THe intention is to execute a system command
> on machine A and watch the result on machine B.
>
> The above codes do NOT work.
> It gives
>   error in application
>   Application of non-procedure and non-object
>   In statement: {<Resource> 108|115| ...}
>
> --------------------------------------------------------------
>
> How do I make it right ?
>
> thanks
> HP
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to