Making system calls on Windows

Anything that doesn't fit elsewhere.
Post Reply
bsuter
Posts: 42
Joined: Fri May 28, 2010 9:04 am

Making system calls on Windows

Post by bsuter »

My goal: write a hoc convenience function for saving data from a simulation run to disk as multiple files and then archiving these files into a single .zip file.

My initial approach (using a simplified test case):

Code: Select all

system("7z a testfile.zip sv.dat")
My problem: when I call system("stringcommand"), I get error messages indicating that the binary I wish to call (7z.exe) is not found:

Code: Select all

sh:  7z: not found
          127
At first I thought this was a Windows path issue, but the same problem occurs when I use a full path to the 7z.exe binary. I've made sure that 7z.exe is in the Windows PATH environment variable. The above call works when executed at the Windows command line, but not from system() within Neuron.

I suspect the problem has to do with the difference between Windows path and Cygwin path (I'm using NEURON 7.2 for this project). Any suggestions for how to resolve this issue? A way to access arbitrary binaries from within NEURON, perhaps? Thank you.

PS: I keep my model code platform-agnostic, in general, and have run my models on Mac and on Windows. In this instance a Windows-specific solution is okay for me, because it's just a convenience method for a specific set of runs that I'll be performing under Windows.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Making system calls on Windows

Post by ted »

Unless you have a very specific reason for sticking with 7.2, I'd suggest moving to 7.4. Would also consider having NEURON do all this file mongering with Python, in the interests of ending up with cross-platform portable code.
bsuter
Posts: 42
Joined: Fri May 28, 2010 9:04 am

Re: Making system calls on Windows

Post by bsuter »

Unless you have a very specific reason for sticking with 7.2
Is 7.4 fully backwards compatible with models made under 7.2?

I plan to use 7.4 for new models. I'm currently revisiting a model made under 7.2 looking to obtain a quick answer to a few minor changes in parameters, so I'd hoped to achieve this without upgrading NEURON and (potentially) running into cross-version issues.
I'd suggest moving to 7.4.
Will doing so solve my current problem, namely that system() doesn't see (some?) binaries on my Windows path?
Would also consider having NEURON do all this file mongering with Python, in the interests of ending up with cross-platform portable code.
I look forward to trying this. For now I'd like to work with my existing models as is - without immediately learning the new Python-hybrid approach. As I mentioned, my routinely run my models on Mac and Windows, so far without any problems - here I was just hoping to implement a quick ZIP-based approach to saving model output for one specific use case. If that's not possible, I'll go back to manually generating ZIP archives after I save to .dat files from hoc.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Making system calls on Windows

Post by ted »

bsuter wrote:Is 7.4 fully backwards compatible with models made under 7.2?
Plus or minus whatever bugs were present in 7.2 that have been fixed in 7.4, and whatever new bugs might be in 7.4 that weren't in 7.2. NEURON's development process includes regression testing to verify backwards compatibility.
I'd hoped to achieve this without upgrading NEURON and (potentially) running into cross-version issues.
The chief cross-version issues are principally due to MicroSoft or Apple (accidentally, we hope) breaking installation and other things that worked. In recent years this has been much more of a problem for OS X than for MSWin.
I'd suggest moving to 7.4.
Will doing so solve my current problem, namely that system() doesn't see (some?) binaries on my Windows path?
Maybe, maybe not. What it will do is help you avoid working hard to get something going under cygwin, only to have to abandon that solution when you eventually update, because 7.4 has switched from cygwin to mingw, and future development will continue with mingw.
bsuter
Posts: 42
Joined: Fri May 28, 2010 9:04 am

Re: Making system calls on Windows

Post by bsuter »

I'd suggest moving to 7.4.
Will doing so solve my current problem, namely that system() doesn't see (some?) binaries on my Windows path?
Maybe, maybe not. What it will do is help you avoid working hard to get something going under cygwin, only to have to abandon that solution when you eventually update, because 7.4 has switched from cygwin to mingw, and future development will continue with mingw.
I have not found a way to get system() to work properly under 7.2/cygwin, and I have not yet upgraded to 7.4/mingw. I'll settle for manually zipping the data files for now. Thanks for your info on the new versions.

If anyone knows how to get 7.2/cygwin system() calls to see executables on the Windows PATH, please let me know.
Post Reply