tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/5064-shell-script-to-launch-moneydance-from-terminal-command-lineInfinite Kind: Discussion 2021-07-14T13:00:23Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-03-14T02:47:14Z2021-03-14T02:47:14ZShell script to launch Moneydance from Terminal Command line<div><p>Thanks Stuart. I've book-marked this. I'm sure I'll have cause to investigate it one day!</p></div>tgilbert666tag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-03-19T14:00:54Z2021-04-09T04:11:33ZShell script to launch Moneydance from Terminal Command line<div><p>It's good to see -invoke_and_quit is still around, I used that in my old networth.py hack. Do you know if there's a mechanism to pass parameters to the python script to run? I haven't investigated yet.</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-03-19T19:29:24Z2021-03-19T19:29:24ZShell script to launch Moneydance from Terminal Command line<div><p>I haven't tested it but my read of the code was that whilst it detects a PY script, it actually ignores this and doesn't run it - needs testing.. If you do test, let me know? As regards invoke and quit, you pass the URI to all an extension and in this you pass a parameter.... (again, not tested)</p>
<p>(not support, just a fellow user)</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-03-20T01:57:12Z2021-04-09T04:11:34ZShell script to launch Moneydance from Terminal Command line<div><p>I will be taking a closer look at this, likely pretty soon, as I have my old networth program actually running already, somewhat to my amazement.</p>
<p>I did notice the script has a lot of Mac-specific stuff, I'm running on Linux. I've been using the MoneyBot Python console for all this. I had had been running my program with this:</p>
<p>/opt/Moneydance/moneydance -invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/networth.py</p>
<p>This current system wants to start Moneydance with /opt/Moneydance/Moneydance. It's a Linux-specific shell script, I'll pass on anything that seems interesting.</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T13:09:39Z2021-04-13T13:09:39ZShell script to launch Moneydance from Terminal Command line<div><p>Yeah, your script is way more Mac specific than I want to deal with. e.g. paths like "-Duser.dir="${my_user_path}/Library/Containers/com.infinitekind.MoneydanceOSX/Data" simply don't exist anywhere on my Linux system. I'll abandon it.</p>
<p>FWIW, on my Linux installation (run as root), the startup script expands into an equally ugly command line. With spaces and colons replaced with line breaks, I ultimately see:</p>
<p>$ cat Desktop/Moneydance.desktop #!/usr/bin/env xdg-open [Desktop Entry] Type=Application<br>
Name=Moneydance<br>
Exec=/bin/sh "/opt/Moneydance/Moneydance"<br>
Icon=/opt/Moneydance/.install4j/Moneydance.png</p>
<p>$ /bin/sh -x "/opt/Moneydance/Moneydance" ... exec \<br>
/opt/Moneydance/jre/bin/java \ -client \ -Dinstall4j.jvmDir=/opt/Moneydance/jre \ -Dexe4j.moduleName=/opt/Moneydance/Moneydance \ --add-modules \ javafx.swing,javafx.controls,javafx.graphics \ -Dinstall4j.launcherId=4 \ -Dinstall4j.swt=false \ -Di4jv=0 \ -Di4jv=0 \ -Di4jv=0 \ -Di4jv=0 \ -Di4jv=0 \ -Xmx1024m \ -Di4j.vpt=true \ -classpath \ /opt/Moneydance/.install4j/i4jruntime.jar: /opt/Moneydance/lib/activation.jar: /opt/Moneydance/lib/antlr-3.2.jar: /opt/Moneydance/lib/appsrc.jar: /opt/Moneydance/lib/bcprov-jdk16-146.jar: /opt/Moneydance/lib/commons-lang3-3.5.jar: /opt/Moneydance/lib/commons-logging-1.2.jar: /opt/Moneydance/lib/darcula.jar: /opt/Moneydance/lib/dropbox-core-sdk-3.0.11.jar: /opt/Moneydance/lib/gson-2.5.jar: /opt/Moneydance/lib/httpclient-4.5.6.jar: /opt/Moneydance/lib/httpcore-4.4.10.jar: /opt/Moneydance/lib/httpmime-4.5.6.jar: /opt/Moneydance/lib/i4jruntime.jar: /opt/Moneydance/lib/jackson-core-2.7.4.jar: /opt/Moneydance/lib/jcommon-1.0.16.jar: /opt/Moneydance/lib/jfreechart-1.0.13.jar: /opt/Moneydance/lib/json_simple-1.1.jar: /opt/Moneydance/lib/junit-4.10.jar: /opt/Moneydance/lib/mdpython.jar: /opt/Moneydance/lib/moneydance.jar: /opt/Moneydance/lib/natty-0.3.jar: /opt/Moneydance/lib/PDFRenderer.jar: /opt/Moneydance/lib/sqlitejdbc-v056.jar: /opt/Moneydance/lib/swingx-core-1.6.2.jar: /opt/Moneydance/lib/TableLayout-bin-jdk1.5-2007-04-21.jar \ com.install4j.runtime.launcher.UnixLauncher \ launch \ [hex number that might be a license key] \ 0 \ 0 \ Moneydance</p>
<p>As for your observation "my read of the code was that whilst it detects a PY script, it actually ignores this and doesn't run it - needs testing"</p>
<p>So far I agree completely. As I mentioned elsewhere, I'll explore further and likely start a new discussion. I will note that what would have worked in 2007 doesn't work now:</p>
<p>$ /bin/sh "/opt/Moneydance/Moneydance" "-invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py" ignoring invalid argument: -invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py</p>
<p>I thought I saw it run without the error last night (and with no visible "Hello, world" output), but I may have had Moneydance already running. The shell script may have been a no-op.</p>
<p>Likely not today - I have too many things to do that I set aside while trying to get on speaking terms with Java Swing.</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T13:20:40Z2021-04-13T13:20:40ZShell script to launch Moneydance from Terminal Command line<div><p>One more on invoke_and_quit, see the old (and stale, it refs changes in 2019) but interesting <a href="https://infinitekind.tenderapp.com/discussions/problems/47682-windows-md-20178-1691-command-line-interface-cli-script-bugs#comment_46147450">https://infinitekind.tenderapp.com/discussions/problems/47682-windo...</a></p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T16:28:14Z2021-04-13T16:28:14ZShell script to launch Moneydance from Terminal Command line<div><blockquote>
<p>$ /bin/sh "/opt/Moneydance/Moneydance" "-invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py" ignoring invalid argument: -invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py</p>
</blockquote>
<p>Likely due to quoting issue,</p>
<pre>
<code> "-invoke_and_quit moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py"</code>
</pre>
<p>is being treated as single argument. Also using " with special char such as ? could be problematic due to shell expansion.</p>
<p>My suggestion try</p>
<pre>
<code>... '-invoke_and_quit' 'moneydance:fmodule:jpython:runfile?=/home/werme/moneydance/hello.py'</code>
</pre></div>hleofxquotestag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T16:36:16Z2021-04-13T16:36:34ZShell script to launch Moneydance from Terminal Command line<div><p>A few things:</p>
<ul>
<li>
<p>Yes my script is Mac specific, but you should be able to customise it easily. I suggest you run my toolbox extension and get the file paths from the diagnostic display and then hardcode them into the script.</p>
</li>
<li>
<p>-invoke_and_quit DOES work; so does -invoke (no quit)... I used it to call my own extension. As the 'wizard' says, you can separate the parameter into a separate argument and quote it.. Try that. HOWEVER, it needs to call your extension.. I don't think 'jpython' will work.</p>
</li>
<li>
<p>the argument option to pass a python script doesn't work... So you need to invoke your extension.</p>
</li>
</ul>
<p>I am thinking of writing a generic python extension that users can invoke to run scripts from the command line....</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T19:11:37Z2021-04-13T19:11:37ZShell script to launch Moneydance from Terminal Command line<div><p>@ hleofxquotes:</p>
<p>Hey, I just cut & pasted something that worked in the old Jython interface in 2007.</p>
<p>The quoting is likely ineffective, when shells can't do filename expansion (i.e. that '?'), they either report the error or pass the string as typed. The double quotes disabled the filename expansion anyway. [They would permit expanding $foo, single quotes would prevent even that.] I never did understand why there was that '?' anyway. I like the suggestion to make '-invoke_and_quit' stand alone I'll play with that, maybe after this Jackson Lab webinar that just started. It may well be that the old startup script managed to split those words (passing quoted strings around shell scripts gets weird).</p>
<p>I had also tried replacing 'jython' with 'python', no good, but per the above, that may be expected.</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T19:33:16Z2021-04-13T19:33:50ZShell script to launch Moneydance from Terminal Command line<div><p>Well... I just used my launch script with these parameters:</p>
<pre>
<code>./launch-moneydance.sh "/Users/stu/Library/Containers/com.infinitekind.MoneydanceOSX/Data/Documents/FAKE2.moneydance" "-invoke=moneydance:fmodule:toolbox:hello?bob"```</code>
</pre>
<p>and MD launched and called my toolbox.invoke() - see response in console:</p>
<pre>
<code>toolbox: @@ invoke script invoked... Parameter: hello?bob</code>
</pre>
<p>So the ? worked when the whole argument was wrapped in quotes..</p>
<p>NOTE - there used to be an internal extension called jpython - this was the way that MD ran jython - BUT IT CHANGED and became core code (Moneybot etc) and hence there is NO jpython extension you can invoke. You have to call your own extension...</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T21:25:55Z2021-04-13T21:25:55ZShell script to launch Moneydance from Terminal Command line<div><p>Okay, -invoke_and_quit is happier by itself on the command line, as is -invoke.</p>
<p>neither gripes that moneydance:fmodule:python:runfile=/home/werme/moneydance/xxx.py' has either a bogus whatever its is to the left of '=' or that xxx.py doesn't exist.</p>
<p>So, if I need an extension to call my code, it looks like that will be a bigger learning curve than I can deal with for a couple weeks.</p>
<p>I guess your <a href="https://raw.githubusercontent.com/yogi1967/MoneydancePythonScripts/master/source/extension_tester/readme.txt">https://raw.githubusercontent.com/yogi1967/MoneydancePythonScripts/...</a> is the best starting point.</p>
<p>I see in <a href="https://yogi1967.github.io/MoneydancePythonScripts/">https://yogi1967.github.io/MoneydancePythonScripts/</a> says "My scripts and extensions are identical. The extension version(s) are simply a ‘packaged’ script version."</p>
<p>That sounds easy, bu the former page says "the mxt contains your *.py file(s) and script_info.dict at root level, and then..: - meta_info.dict in a sub directory structure called ./com/moneydance/modules/features/extension_name/</p>
<p>I see elsewhere I have to change networth.py to make it runnable as an extension. I think I see a learning curve....</p>
<p>Let me know if you write an extension that runs a python script.</p>
<p>-Ric</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-13T21:48:41Z2021-04-14T14:48:23ZShell script to launch Moneydance from Terminal Command line<div><p>Ric. Do you want to email me directly? Perhaps send me your networth.py file</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-14T12:28:37Z2021-04-14T12:28:37ZShell script to launch Moneydance from Terminal Command line<div><p>I'll do that. I spent most of Monday cleaning up code and dealing with a couple loose ends, I have to prepare a mailing list for the local Mensa newsletter, a task that's more messier in April than most months, and get busy buying a new car, and prepping for an exhaust fan in the garage, etc....</p>
<p>Give me a couple days, remaining loose ends won't take long or can be deferred.</p></div>Ric Wermetag:infinitekind.tenderapp.com,2009-01-14:Comment/490835862021-04-14T12:55:31Z2021-04-14T12:55:31ZShell script to launch Moneydance from Terminal Command line<div><p>Don't worry about cleaning it up, just email it to me directly. I will send you back a way to update the code as you see fit whenever you are ready.... S</p></div>Stuart Beesley (Mr Toolbox)