Multiple instances of Gnucash in moutain lion
Joe R
jxr2000 at lycos.com
Sun Nov 18 09:52:21 EST 2012
Hi Gentlemen,
I believe with tips from both of you and a bit of reading from the Bash
scripting reference I was able to figure this out to a satisfactory
conclusion.
This is the script that I wrote and works very well
#! /bin/bash
# Start Gnucash passing a file to open
# start a subshell as to not tie the terminal
#
# change to dir where file resides
cd /Volumes/Financial/Banking/Accounting
# start subshell to exec Gnucash
(/Applications/Gnucash.app/Contents/MacOS/Gnucash PersonalAccounting &)
exit
I have also tried it on a terminal and it works. The & does work but
like John said is misleading since you don't see the prompt, but typing
exit gets you out of the shell. If you don't provide the & than you
don't get a prompt until you quit Gnucash and typing exit before
quitting Gnucash doesn't do anything.
This solves my issue and I am happy with it.
I appreciate all your help. An interesting problem indeed.
Joe.
on Nov 17, 2012, John Ralls <jralls at ceridwen.us> wrote:
On Nov 18, 2012, at 12:13 AM, Lincoln A Baxter
<[1]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 <[2]jralls at ceridwen.us>
wrote:
>>
>>>
>>> On Nov 16, 2012, at 7:46 AM, Joe R <[3]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
_______________________________________________
gnucash-user mailing list
[4]gnucash-user at gnucash.org
[5]https://lists.gnucash.org/mailman/listinfo/gnucash-user
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.
References
1. mailto:lab at lincolnbaxter.com
2. mailto:jralls at ceridwen.us
3. mailto:jxr2000 at lycos.com
4. mailto:gnucash-user at gnucash.org
5. https://lists.gnucash.org/mailman/listinfo/gnucash-user
More information about the gnucash-user
mailing list