<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Running Python Script from JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/45510#M26015</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x = RunProgram(
	executable( "/path/anaconda/bin/python" ),
	options( "/path/filename.py" ),
	readfunction( "blob" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then to do the opposite, run JSL from a python script.&amp;nbsp; This works on a Mac, JMP 13.2&amp;nbsp; (and this is python not jsl)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;import os&lt;BR /&gt;
os.system('open /Applications/JMP\ Pro\ 13.app/Contents/MacOS/JMP /path/script.jsl')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the open argument has the application path, one space and then the path/file to open.&lt;/P&gt;
&lt;P&gt;Its probably imporant to have&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//!&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;on the first row of the script so it will auto run. And then on the last line, include this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Quit();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will close the instance of JMP that os.sytem started.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 03:08:32 GMT</pubDate>
    <dc:creator>Byron_JMP</dc:creator>
    <dc:date>2017-10-05T03:08:32Z</dc:date>
    <item>
      <title>Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34283#M20305</link>
      <description>&lt;P&gt;I would like to run Python script from my JSL code. What is the best way to do that? Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 17:24:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34283#M20305</guid>
      <dc:creator>felix_doktorman</dc:creator>
      <dc:date>2017-01-07T17:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34284#M20306</link>
      <description>Use the &lt;BR /&gt;     RunProgram()&lt;BR /&gt;function.&lt;BR /&gt;For details, go to:&lt;BR /&gt;    Help==&amp;gt;Scripting Indes==&amp;gt;RunProgram</description>
      <pubDate>Sat, 07 Jan 2017 17:28:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34284#M20306</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-01-07T17:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34293#M20315</link>
      <description>&lt;P&gt;Here's an example I was playing with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt=runprogram(executable("python"),options({"C:\Users\User\Desktop\tweepy\twpy2.py"}),readfunction("text"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Tweepy is a python package for twitter. &amp;nbsp;This example expects the python program to start, produce output, and terminate, before the JSL continues. &amp;nbsp;There are other ways to use RunProgram.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 03:42:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/34293#M20315</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-01-09T03:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42706#M24773</link>
      <description>&lt;P&gt;I'm struggling with the 'run program' command. &amp;nbsp;The line below works fine from a command prompt:&lt;/P&gt;
&lt;P&gt;c:\mycompany\anaconda3\python.exe "c:\users\myuserid\temp\pythonsqltest.py"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to run it by executing this script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
RP = RunProgram(
Executable( "c:\mycompany\anaconda3\python.EXE" ),
Options( {"c:\users\myuserid\temp\pythonsqltest.py"} ),
ReadFunction( Function( {this}, Write( this &amp;lt;&amp;lt; read ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking I don't really understand the role 'ReadFunction' plays here. &amp;nbsp;What am I missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 13:12:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42706#M24773</guid>
      <dc:creator>vt_sailor</dc:creator>
      <dc:date>2017-08-02T13:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42731#M24776</link>
      <description>&lt;P&gt;readFunction tells RunProgram how to deal with the output of your python program (the data written to stdout). If you supply an actual JSL function, compiled by the &lt;EM&gt;function&lt;/EM&gt; function, as in your example, then JSL and python are running independently and whenever JMP is idle, your JSL function can be called to retrieve some more output from python. This might be useful if the python program runs forever and makes an infinite stream of output. The other example posted here uses &lt;EM&gt;readfunction("text")&lt;/EM&gt;, which is a simple way to get back all of the output from the python program (which must terminate, of course). The output comes back as the result of the runProgram function.&lt;/P&gt;
&lt;P&gt;If you supply a function for runProgram to call, then you must also keep the runprogram object in a JSL variable so the connection between JMP and Python isn't destroyed too soon: &lt;EM&gt;obj&lt;/EM&gt; = runProgram(...)&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;this&lt;/EM&gt; parameter in the readFunction is the same as the &lt;EM&gt;obj&lt;/EM&gt; variable above. It gives you access to the methods of the runProgram object, like &amp;lt;&amp;lt;read.&lt;/P&gt;
&lt;P&gt;edit: And the output of the write function goes to the JMP log; be sure to look there for your results.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 14:21:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42731#M24776</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-08-01T14:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42741#M24777</link>
      <description>Craig,&lt;BR /&gt;&lt;BR /&gt;Thank you for the quick response. What I'm trying to do is to call the&lt;BR /&gt;python program and pause execution of the JSL until the python program&lt;BR /&gt;terminates. The python program writes its output to a file which I would&lt;BR /&gt;then open and retrieve via JSL. I'm basically trying to use Python to&lt;BR /&gt;retrieve data from a database for use by my JSL code. The sequence should&lt;BR /&gt;be:&lt;BR /&gt;&lt;BR /&gt;1. Run JSL and prepare the SQL query, this then gets pulled together to&lt;BR /&gt;create the python script.&lt;BR /&gt;2. Run the python program and pause the JSL&lt;BR /&gt;3. When the python completes the JSL continues, opening up the file&lt;BR /&gt;python saved and processing it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2017 14:28:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42741#M24777</guid>
      <dc:creator>vt_sailor</dc:creator>
      <dc:date>2017-08-01T14:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42755#M24778</link>
      <description>&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;txt = runprogram( ... readfunction("text"));&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If the python program produces any stdout (print statement, etc) it will come back to JSL as the result of runProgram. JSL won't continue until the Python program terminates with &lt;EM&gt;readfunction("text")&lt;/EM&gt;. You might want to print something like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename.dat,100&lt;/P&gt;
&lt;P&gt;so JSL can know there are 100 lines of data in that file. Or print an error message and handle that if the database is unavailable.&lt;/P&gt;
&lt;P&gt;(JSL also has some SQL capabilities that might be more appropriate&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1947"&gt;@Eric_Hill&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 15:12:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42755#M24778</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-08-01T15:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42756#M24779</link>
      <description>&lt;P&gt;Might be simpler and faster to read data directly in to JMP using an ODBC driver. &amp;nbsp;What's your SQL database? &amp;nbsp;I have a lot of experience with Oracle and could help with&amp;nbsp;that.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 15:20:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42756#M24779</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-01T15:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42757#M24780</link>
      <description>&lt;P&gt;I'm using the ODBC drivers now and they are not reliable. &amp;nbsp;I don't really think it's JMP but switching from JMP 12 - 13 and oracle 11-12 definitely upset the applecart. &amp;nbsp;I know have to close and reopen the database connections about every five queries in order for things to run reliably.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 15:35:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42757#M24780</guid>
      <dc:creator>vt_sailor</dc:creator>
      <dc:date>2017-08-01T15:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42759#M24782</link>
      <description>&lt;P&gt;I'm using Oracle's&amp;nbsp;64-bit ODBC driver for Oracle 11 to talk to an Oracle v12 database. &amp;nbsp;I haven't seen any behavior like you mentioned. &amp;nbsp;I've used this for JMP 11 and 12. &amp;nbsp;We haven't transitioned fully to JMP 13 yet; v13.1.0 fixed a bug where V13.0 couldn't read a CLOB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could never get the Oracle ODBC driver from Microsoft to work btw.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 15:51:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/42759#M24782</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-01T15:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/45510#M26015</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x = RunProgram(
	executable( "/path/anaconda/bin/python" ),
	options( "/path/filename.py" ),
	readfunction( "blob" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then to do the opposite, run JSL from a python script.&amp;nbsp; This works on a Mac, JMP 13.2&amp;nbsp; (and this is python not jsl)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;import os&lt;BR /&gt;
os.system('open /Applications/JMP\ Pro\ 13.app/Contents/MacOS/JMP /path/script.jsl')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the open argument has the application path, one space and then the path/file to open.&lt;/P&gt;
&lt;P&gt;Its probably imporant to have&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//!&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;on the first row of the script so it will auto run. And then on the last line, include this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Quit();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will close the instance of JMP that os.sytem started.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 03:08:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/45510#M26015</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2017-10-05T03:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Running Python Script from JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/221590#M44224</link>
      <description>&lt;P&gt;Update: Since JMP 14.0 (and much improved in 15.0), the best way to run Python from JSL is now to use the JMP interface implemented in the commands Python Init(), Python Submit(), etc.&lt;/P&gt;
&lt;P&gt;More information here:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/14-2/python-integration-functions.shtml" target="_blank"&gt;https://www.jmp.com/support/help/14-2/python-integration-functions.shtml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For a wrapper that supports running Anaconda virtual environments, check:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-Scripts/Anaconda-Environments-Integration/ta-p/221565" target="_blank"&gt;https://community.jmp.com/t5/JMP-Scripts/Anaconda-Environments-Integration/ta-p/221565&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 00:25:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Running-Python-Script-from-JSL/m-p/221590#M44224</guid>
      <dc:creator>nascif_jmp</dc:creator>
      <dc:date>2019-08-14T00:25:29Z</dc:date>
    </item>
  </channel>
</rss>

