<?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 JSL write to stdout in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457848#M70297</link>
    <description>&lt;P&gt;I'm running a JSL script from powershell core on windows.&amp;nbsp; Does anyone have a good way to write to console from JSL so that it writes out to my powershell script?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Currently I'm writing to a temp file and then in the powershell script checking that file in a loop and writing the contents of that file.&amp;nbsp; Hoping someone has done something more robust.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 18:09:58 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2023-06-09T18:09:58Z</dc:date>
    <item>
      <title>JSL write to stdout</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457848#M70297</link>
      <description>&lt;P&gt;I'm running a JSL script from powershell core on windows.&amp;nbsp; Does anyone have a good way to write to console from JSL so that it writes out to my powershell script?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Currently I'm writing to a temp file and then in the powershell script checking that file in a loop and writing the contents of that file.&amp;nbsp; Hoping someone has done something more robust.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:09:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457848#M70297</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2023-06-09T18:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: JSL write to stdout</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457888#M70300</link>
      <description>&lt;P&gt;It sounds like you need to make a DLL. JMP works well with those that have a single parameter. That argument could be your string.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 19:21:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457888#M70300</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-02-02T19:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: JSL write to stdout</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457891#M70303</link>
      <description>&lt;P&gt;Cool.&amp;nbsp; I'll look into it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 19:45:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457891#M70303</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2022-02-02T19:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: JSL write to stdout</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457966#M70314</link>
      <description>&lt;P&gt;You could do something like this. Here's (my first ever, more-or-less) powershell script (thanks github and stack overflow!) Fix up the path to the desktop file...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
Write-Output "Starting JMP"
Start-Process -FilePath "jmp.exe" -ArgumentList "C:\Users\v1\Desktop\pstest.jsl"
Write-Output "Started JMP"

# https://gist.github.com/staaldraad/153ab9d26d49c387550bcb5f974f7910
# thanks @ https://gist.github.com/staaldraad
$socket = new-object System.Net.Sockets.TcpListener('0.0.0.0', 1080);
if($socket -eq $null){
	exit 1;
}
$socket.start();
$client = $socket.AcceptTcpClient();
$stream = $client.GetStream();
$buffer = new-object System.Byte[] 2048;
# $file = 'c:/afile.exe';
# $fileStream = New-Object System.IO.FileStream($file, [System.IO.FileMode]'Create', [System.IO.FileAccess]'Write');

$encoding = new-object System.Text.AsciiEncoding

do
{
	$rawresponse = $null;
	while($stream.DataAvailable -or $rawresponse -eq $null) {
			$rawresponse = $stream.Read($buffer, 0, 2048);
			if ($rawresponse -gt 0) {
				$response = $encoding.GetString($buffer, 0, $rawresponse)
# 				$fileStream.Write($buffer, 0, $read);
				$response # really? that's all it takes to print to the console?
			}
		}
} While ($rawresponse -gt 0);

# $fileStream.Close();
$socket.Stop();
$client.close();
$stream.Dispose();

Write-Output "all done, exit in 5 seconds..."
Start-Sleep -Seconds 5
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's a JSL script, pstest.jsl, for the Desktop...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;s=socket();
s&amp;lt;&amp;lt;connect("localhost","1080");
s&amp;lt;&amp;lt;send(chartoblob("hello world!"));
s&amp;lt;&amp;lt;close();
quit();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think this was required, but can't be sure after a couple of false starts...&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dialog from windows to allow PowerShell to open a port." style="width: 560px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39682i48EE626B3011A8EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="AllowAccess.PNG" alt="Dialog from windows to allow PowerShell to open a port." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Dialog from windows to allow PowerShell to open a port.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And eventually&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Right-click the .PS1 script on the desktop and -&amp;gt;Run in PowerShell." style="width: 364px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39683i68610C6F77D9C2B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="RunningPowerShell.PNG" alt="Right-click the .PS1 script on the desktop and -&amp;gt;Run in PowerShell." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Right-click the .PS1 script on the desktop and -&amp;gt;Run in PowerShell.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 04:35:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-write-to-stdout/m-p/457966#M70314</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-02-03T04:35:07Z</dc:date>
    </item>
  </channel>
</rss>

