Multiple instances of Gnucash in moutain lion

John Ralls jralls at ceridwen.us
Sat Nov 17 20:03:57 EST 2012


On Nov 18, 2012, at 12:13 AM, Lincoln A Baxter <lab at lincolnbaxter.com> wrote:

> On Fri, 2012-11-16 at 09:59 +0900, John Ralls wrote:
>> On Nov 16, 2012, at 8:43 AM, John Ralls <jralls at ceridwen.us> wrote:
>> 
>>> 
>>> On Nov 16, 2012, at 7:46 AM, Joe R <jxr2000 at lycos.com> wrote:
>>> 
>>>> Hi John,
>>>> 
>>>> That works but there is a catch. It ties up your terminal even if you put the & at the end. What I will do is create a script that will do the following:
>>>> 
>>>> CD into lib of where the file I want to use is
>>>> start Gnucash file-i-want
>>>> Exit
>>>> 
>>>> This terminal session will stay active will I work with Gnucash, and once I quit from it, it should close due to the Exit cmd.
>>>> 
>>>> I will assign an icon to each script so I know which is which copy it to the dock and I should be good to go.
>>>> 
>>>> If this works, which it should I can live with it.
>>> 
>>> Please always CC the list on replies: Use "reply all" (the double-arrow thingy).
>>> 
>>> No, it doesn't tie up the terminal session when you background it, it just looks that way because Gnucash writes some stuff to stdout that make the prompt hard to see. Try typing another command or launching another instance of Gnucash after the first.
>>> 
>> 
>> Well, poop. I realized about 2 minutes after writing that that doing anything in the terminal session immediately suspends Gnucash. Even redirecting the output doesn't do it. There must be something about the exec at the end that's attaching it to the terminal session. I'll have to dig into that a bit more.
>> 
> 
> I'm guessing Joe are running on Windows? and writing the script using a
> cmd.exe?  If so, try installing cygwin bash... and scripting in bash.  
> 
> In bash (if you are using it), you don't want to 'exec.' That executes
> the command named in the context of the current process.  And the '&'
> means nothing.  I think you just want to run the gnucash command (in
> windows gnucash.exe) and then put the & at the end of the command line.
> Remember to redirect stdout and stderr:
> 
>  gnucash file 2>&1 /dev/null &
>  exit
> 
> This will create a detached subprocess executing gnucash and allow the
> parent process (running the terminal window to continue, it will then
> get to the exit command and should exit closing the terminal window.
> I'm sure it works this way on Posix OSes.

Well, we're talking about OSX, but the bash part is right. Thanks for confirming my suspicion of "exec". '&' does do *something*, it provides a shell prompt, but interacting with the shell immediately stops Gnucash, so '&' doesn't do anything *useful*.

The problem with your suggestion about running gnucash as a separate process is that the launcher script is actually intended to run Gnucash when it's started by LaunchServices, and I'm not sure in that case that it will inherit the environment we've set up in the rest of the script. I'll have to experiment with it, which I don't have time to do now.

Regards,
John Ralls




More information about the gnucash-user mailing list