nrniv auto exiting

Post Reply
sl
Posts: 21
Joined: Wed Nov 28, 2007 12:52 am
Location: Cornell University

nrniv auto exiting

Post by sl » Mon Jul 07, 2008 4:42 pm

There is probably a simple solution for this, but it escapes me.

When I run this from the command line:

Code: Select all

nrniv test.hoc
It runs the .hoc file and exits, even though there is no quit() statement in the file. nrngui does the same, and nrnoc just plain refuses to work. I would like the behavour to be exactly the same as if I just did:

Code: Select all

nrniv
load_file("test.hoc")
Also, doing:

Code: Select all

nrniv -c "load_file(\"test.hoc\")"
did not work either.

Thanks!

JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Re: nrniv auto exiting

Post by JimH » Tue Jul 08, 2008 9:59 pm


ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: nrniv auto exiting

Post by ted » Wed Jul 09, 2008 3:33 pm

sl wrote:When I run this from the command line:

Code: Select all

nrniv test.hoc
It runs the .hoc file and exits
This is as it should be. To prevent exit after program execution, change the command line to

Code: Select all

nrniv test.hoc -
as Jim H suggests.
nrngui does the same, and nrnoc just plain refuses to work
I doubt that anyone has used nrnoc for a long time, and would not be surprised to discover that it is buggy, under the general principles that "stuff happens" and "software that is rarely used is highly likely to have bugs."
nrngui test.hoc should not exit, unless test.hoc contains a statement that forces exit. What does test.hoc contain? What version of NEURON are you using, and did you compile from source code or install from the rpm file? If the former, what special compile options did you select, if any? What version of UNIX or Linux are you using?

Code: Select all

nrniv -c "load_file(\"test.hoc\")"
did not work either.
It shouldn't.

sl
Posts: 21
Joined: Wed Nov 28, 2007 12:52 am
Location: Cornell University

Starting NEURON by double clicking on a hoc file under Linux

Post by sl » Wed Jul 09, 2008 9:40 pm

Thank you ted and JimH. You're right `nrngui test.hoc` does work as expected. The reason why I thought it didn't is because of the way the double-click launch works on Ubuntu. What I wanted to do is to replicate the Windows' version functionality of being able to double click on the .hoc file and have nrniv launch it. I did end up solving it in the end though. Here's my solution, in case anyone finds it useful. Note that it probably only works on Ubuntu.

First you need to register .hoc as a separate MIME type from the normal plain-text files.
Call up the terminal and type in this:

Code: Select all

gksudo gedit /usr/share/mime/packages/freedesktop.org.xml
Then, add the following lines somewhere inside it near the other MIME types.

Code: Select all

  	<mime-type type="text/x-hoc">
	<sub-class-of type="text/plain"/>
	<comment>hoc code</comment>
	<glob pattern="*.hoc"/>
	</mime-type> 
For some older versions of GNOME it helps to make it be a subset of "test/x-csrc" instead. Try it if it complains about filetypes being wrong

Now, exit gedit and type in this:

Code: Select all

sudo update-mime-database /usr/share/mime
and then:

Code: Select all

gksudo gedit /usr/local/bin/nrn
Put this into the opened file:

Code: Select all

#!/bin/bash
DIR=`dirname "$1"`
gnome-terminal -e "nrniv $1 - -dll ./x86_64/.libs/libnrnmech.so" --working-directory="$DIR"
Note:Replace ./x86_64/.libs/ by something else, if your nrnivmodl puts the libnrnmech.so in a different place
Close gedit again and type in:

Code: Select all

gksudo nautilus /usr/local/bin
Find the 'nrn' file you created, right click it, click properties and go to the Permissions tab. Make sure the 'Allow executing file as a program' check box is checked.
Now, find a .hoc file and right click that.
Click Properties->Open With->Add->use custom command
In that edit box, type in 'nrn'.

Now, upon double clicking the terminal will pop up with the hoc file opened. Also, if you compiled the mechanisms the nrniv should have loaded those as well.
Last edited by sl on Wed Jul 15, 2009 11:26 am, edited 3 times in total.

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Starting NEURON by double clicking on a hoc file under Linux

Post by ted » Fri Jul 11, 2008 3:40 pm

Thanks for working that out and sharing your solution. While most current NEURON users who work in a Linux environment are using the command line exclusively, you have just made NEURON more accessible to those who are more familiar with the "double click" approach to launching programs.

Post Reply