Bill,

I needed exactly this and modified tasks.ijs to permit me.  The changes are 
simple.  First,  

        open 'task'

then find the definition of  CreateProcessF_jtask_  , which is on line 77 and 
change it from this:
   
     CreateProcessF=: 'kernel32 CreateProcessA i i *c i i i  i i i *c *c' &cd

to this:
   
     CreateProcessF=: 'kernel32 CreateProcessA i i *c i i i  i i *c *c *c'&cd

then find the definition of  CreateProcess_jtask_  which is on line 109, and 
change the 20th line of the definition (the 129th line of the file) from:

     'r i1 c i2 i3 i4 f i5 i6 si pi'=. CreateProcessF 0;y;0;0;inh; f;0;0;si;pi

to  

     'r i1 c i2 i3 i4 f i5 i6 si pi'=. CreateProcessF 0;y;0;0;inh; f;0;cwd;si;pi

and add this line just above that one:

     if. 0 = L.y do. cwd=.<0 else. 'y cwd'=.y end.

Now you can call the various utilities exported from task as usual, or you may 
pass a working directory for the call by linking it to the usual argument, 
thus:  

     shell 'executable';'current working directory'

By the way, you needn't use fread, fwrite, etc.  If your utility supports stdin 
and stdout (a good bet under cygwin), you can just use the dyad spawn:  

     stdout  =. 'stdin' spawn 'executable' NB.  Or, now,  
'executable';'directory'

I even have a utility (which relies on the changes detailed above) which lets 
me execute arbitrary bash scripts:

     bash =: verb define
          y spawn~ 'C:\cygwin\bin\bash.exe --login';'C:\cygwin\bin\'
     )

thanks to Oleg for his help getting this working, in   
http://www.jsoftware.com/pipermail/programming/2007-February/005128.html  .

-Dan   
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to