Here is another test, this time with redirection, and using hostcmd. When foo is run, it should wait 2 seconds and return its (string) argument. If this works, try the same with synmod.exe.
T=: jpath '~temp/' F=: T,'t1.sh' G=: T,'t2.txt' H=: T,'t3.txt' F fwrites~ '#!/bin/bash',LF,'sleep 2',LF,'read var',LF,'echo $var' fmakex F foo=: 3 : 0 G fwrites~ y H fwrites~ '' hostcmd_j_ F,' < ',G,' > ', H smoutput freads H ) foo 'hello' On Sat, Nov 25, 2017 at 10:22 AM, J. Patrick Harrington <[email protected]> wrote: > Chris, > I have finally got back to my mac to test this. I have installed > the latest j806 to make sure it's up to date (and tried this with j805 > with the same results as reported here). Both pass your test: > > F=: jpath '~temp/t1.sh' > F fwrites~ '#!/bin/bash',LF,'sleep 2',LF,'echo "done"' > 32 > fmakex F > foo=: 3 : 0 > echo 2!:0 F > echo 2+3 > ) > foo'' > done > > 5 > > The mac is a late 2014 mini running OS 10.12.6 (Sierra). > JVERSION > Engine: j806/j64nonavx/darwin > Release: commercial/2017-11-06T10:18:00 > Library: 8.06.09 > Qt IDE: 1.6.2s/5.6.3 > Platform: Darwin 64 > Installer: J806 install > InstallPath: /users/jph/j64-806 > > But... my program still fails. I can simplify the problem by just entering > one line (after setting the directory to /Users/jph/tlusty205/synspec/j > ph): > 2!:0 '../synmod.exe < fort.5 > fort.6' > Instead of writing the output to fort.6, it dumps that output to the Jqt > session: > ... > PARTITION FUNCTIONS AT THE STANDARD DEPTH > ------------------------------------------ > > > H 4.58E+00 1.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > He 1.00E+00 2.00E+00 1.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > Li 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > Be 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > B 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > C 1.19E+02 6.12E+00 1.04E+00 2.01E+00 1.00E+00 0.00E+00 0.00E+00 > 0.00E+00 > > etc. > This is just the tail of the 557 line output file. So the > direction of > the script is not followed. But if I go to a terminal shell in the same > directory and enter > ../synmod.exe < fort.5 > fort.6 > it executes without any screen output. And the results are printed to > fort.6. > > On my Dell XPS running 806 under Ubuntu 16.04, > 2!:0 '../synmod.exe < fort.5 > fort.6' > returns to the qt terminal without any screen output, and looking at > fort.6, the expected results have been written there. So there is > some problem about how 2!:0 handles the directed output on the mac as > opposed to the Linux machine. > > I suppose I could work around this by modifing the fortran program to send > the output directly to a file called 'fort.6' instead of directing the > standard output. But it's huge program I didn't write, and I'd rather not. > > Regards, Patrick > > On Wed, 22 Nov 2017, chris burke wrote: > >> You should be able to do a simple test to see if 2!:0 waits, for example >> as >> below. This does wait on my Mac with the same J as you, except the avx >> version. >> >> F=: jpath '~temp/t1.sh' >> F fwrites~ '#!/bin/bash',LF,'sleep 2',LF,'echo "done"' >> fmakex F >> >> foo=: 3 : 0 >> echo 2!:0 F >> echo 2+3 >> ) >> >> foo'' >> >> On Wed, Nov 22, 2017 at 7:28 PM, J. Patrick Harrington <[email protected] >> > >> wrote: >> >> Bill, >>> >>> I've tried that. ../synmod.exe < fort.5 > fort.6 in a terinal >>> window works fine on all three machines. And the directory change >>> is OK. WHen the program fails on the Mac Mini, the J session is >>> left in the /home/tages/tlusty205/synspec/jph directory. >>> >>> Patrick >>> >>> On Thu, 23 Nov 2017, bill lam wrote: >>> >>> You can try executing the cmd in bash shell to verify whether it actually >>>> work on the other machine. >>>> >>>> Also check the cwd in J session to see it is correct. >>>> >>>> On Nov 23, 2017 12:54 AM, "J. Patrick Harrington" <[email protected]> >>>> wrote: >>>> >>>> A>> A problem has surfaced which has me puzzled. I have written a >>>> >>> >>> program which needs the results of another program, synmod.exe, which >>> >>>> reads in a file, executes for a few seconds, and writes the results >>>>> to the file fort.6 (synmod.exe is my modification of a 10,000 line >>>>> fortran program). The relevant part of my program is as follows: >>>>> >>>>> LAM=: IX=: QX=: <'' >>>>> 1!:44 '/home/tages/tlusty205/synspec/jph' >>>>> 'Ti gi lam1 lam2'=. y >>>>> fix55 lam1, lam2 NB. put lam1 & lam2 into fort.55 >>>>> lngg=. 10^. gi >>>>> nh=. -:#Ti >>>>> i=. _1 >>>>> while. (i=. >:i)<nh do. >>>>> Tii=. i{Ti >>>>> lngi=. i{lngg >>>>> Kbicub Tii, lngi >>>>> 2!:0 '../synmod.exe < fort.5 > fort.6' >>>>> Z=. lam2 CLEAN Extract'' >>>>> 'mu rad deg lam Flx Ia Qa pol'=. Z >>>>> LAM=: LAM, <lam >>>>> IX=: IX, <Ia >>>>> QX=: QX, <Qa >>>>> end. >>>>> 1!:44 '/home/tages/J6/SPIN.d' >>>>> >>>>> The issue here is the Foreign 2!:0. This code works *perfectly* on my >>>>> Dell >>>>> laptop running >>>>> JVERSION >>>>> Engine: j806/j64/linux >>>>> Release: commercial/2017-11-06T09:54:01 >>>>> Library: 8.06.09 >>>>> Qt IDE: 1.6.2/5.3.2 >>>>> Platform: Linux 64 >>>>> Installer: J806 install >>>>> InstallPath: /home/tages/j64-806 >>>>> >>>>> But... the very same code running on either of the other two machines I >>>>> use fails. The line 2!:0 '../synmod.exe < fort.5 > fort.6' >>>>> should write the results of synmod to the file fort.6, but >>>>> instead defines fort.6 but writes nothing to it. Thus the >>>>> Extract'' routine fails when it tries to read fort.6. >>>>> >>>>> I suspect that while 2!:0 waits for synmod.exe to finish, maybe >>>>> on my other machines it transfers to the next line of the J code >>>>> before fort.6 is written. One of these machines is a Mac Mini running >>>>> JVERSION >>>>> Engine: j806/j64nonavx/darwin >>>>> Release: commercial/2017-11-06T10:18:00 >>>>> Library: 8.06.09 >>>>> Qt IDE: 1.6.2s/5.6.3 >>>>> Platform: Darwin 64 >>>>> Installer: J806 install >>>>> InstallPath: /users/jph/j64-806 >>>>> >>>>> So I'm asking if the foreign 2!:0 in some cases returns without >>>>> waiting. I thought just 2!:1 did that. >>>>> >>>>> Apologies for the long-winded post, Patrick >>>>> >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>> >>>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >>> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
