<?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: Pass argument when running script from command line in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341234#M58966</link>
    <description>&lt;P&gt;Ok,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm doing it this way for now:&lt;/P&gt;&lt;PRE&gt;'myVariable = "{0}";' -f $variableToPassToJMP | Out-File "./paths.jsl"
Start-Process -FilePath $JMP_path -ArgumentList ("`""+$JMPScriptPath+"`"") -Wait
Remove-Item -Path "./paths.jsl" -Force -Confirm:$false&lt;/PRE&gt;&lt;P&gt;Not very elegant, but works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upd.: Oh, in the JSL script itself I just do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Include("paths.jsl");&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 12 Dec 2020 00:03:44 GMT</pubDate>
    <dc:creator>miguello</dc:creator>
    <dc:date>2020-12-12T00:03:44Z</dc:date>
    <item>
      <title>Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341194#M58962</link>
      <description>&lt;P&gt;I have a JMP script that runs as a part of a larger script written in PowerShell.&lt;/P&gt;&lt;P&gt;I start the JMP script using&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Start-Process -FilePath $JMP_path -ArgumentList ("`""+$JMPScriptPath+"`"") -Wait&lt;/PRE&gt;&lt;P&gt;I'd like to pass an additional argument to a script - just a text string.&lt;/P&gt;&lt;P&gt;How do I do that?&lt;/P&gt;&lt;P&gt;I tried just writing it into an Environmental variable, but while JMP can read it just fine when it runs as a standalone, it cannot read it when JMP starts from within PowersShell. I also would like to avoid writing this string into a file from Powershell script only to read it from JSL script. Maybe there is a way to pass that string to the script? Or maybe I should use Start-Process in a different way so that JMP could read Environmenta variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:00:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341194#M58962</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-06-09T22:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341234#M58966</link>
      <description>&lt;P&gt;Ok,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm doing it this way for now:&lt;/P&gt;&lt;PRE&gt;'myVariable = "{0}";' -f $variableToPassToJMP | Out-File "./paths.jsl"
Start-Process -FilePath $JMP_path -ArgumentList ("`""+$JMPScriptPath+"`"") -Wait
Remove-Item -Path "./paths.jsl" -Force -Confirm:$false&lt;/PRE&gt;&lt;P&gt;Not very elegant, but works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upd.: Oh, in the JSL script itself I just do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Include("paths.jsl");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Dec 2020 00:03:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341234#M58966</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2020-12-12T00:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341280#M58972</link>
      <description>&lt;P&gt;same idea, more or less:&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Jmp.exe arguments" uid="67572" url="https://community.jmp.com/t5/Discussions/Jmp-exe-arguments/m-p/67572#U67572" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2020 01:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341280#M58972</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-12-12T01:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341452#M59018</link>
      <description>Yeah, I saw that post. As I said, JMP for some reason can't read environmental variable when launched from powershell script.</description>
      <pubDate>Sun, 13 Dec 2020 21:52:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341452#M59018</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2020-12-13T21:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341559#M59039</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1492"&gt;@jschroedl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 12:26:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341559#M59039</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-12-14T12:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341584#M59046</link>
      <description>&lt;P&gt;Can you show us how you are setting the environment variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is working for me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;startjmp.ps1:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;$JMP_Path&amp;nbsp;=&amp;nbsp;"C:\Program&amp;nbsp;Files\SAS\JMPPRO\15\jmp.exe"
$JMPScriptPath&amp;nbsp;=&amp;nbsp;"C:\util\test.jsl";
$Env:ScriptArg&amp;nbsp;=&amp;nbsp;"Hello&amp;nbsp;from&amp;nbsp;PowerShell";

Start-Process&amp;nbsp;-FilePath&amp;nbsp;$JMP_Path&amp;nbsp;-ArgumentList&amp;nbsp;("`""+$JMPScriptPath+"`"")&amp;nbsp;-Wait&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;SPAN&gt;test.jsl:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open Log();
myvar&amp;nbsp;=&amp;nbsp;Get&amp;nbsp;Environment&amp;nbsp;Variable("ScriptArg");
print(myvar);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Launched startjmp from PS&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Log output in JMP:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open Log();
myvar = Get Environment Variable("ScriptArg");
print(myvar);
/*:

"Hello from PowerShell"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for the ping&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:46:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341584#M59046</guid>
      <dc:creator>jschroedl</dc:creator>
      <dc:date>2020-12-14T14:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pass argument when running script from command line</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341726#M59069</link>
      <description>&lt;P&gt;I actually set it up like this:&lt;/P&gt;&lt;PRE&gt;[System.Environment]::SetEnvironmentVariable('scriptArg', 'Hello From PowerShell', 'User')&lt;/PRE&gt;&lt;P&gt;...only because as far as I understand, when you set it up like this:&lt;/P&gt;&lt;PRE&gt;$Env:ScriptArg = "Hello from PowerShell";&lt;/PRE&gt;&lt;P&gt;it does not persist beyond powershell session, and when I was testing it by looking via Windows tools, I was getting some strange behavior. However, I don't even need it to persist beyond the session - within the session is perfectly fine, so I'll probably go back to your (and my initial) option, now that I tested it again.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 21:48:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-argument-when-running-script-from-command-line/m-p/341726#M59069</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2020-12-14T21:48:53Z</dc:date>
    </item>
  </channel>
</rss>

