Windows 上の PowerShell コアから JSL スクリプトを実行しています。JSL からコンソールに書き込んで PowerShell スクリプトに書き出す良い方法をご存知の方はいらっしゃいますか?
現在、一時ファイルに書き込み、PowerShell スクリプトでそのファイルをループでチェックし、そのファイルの内容を書き込みます。誰かがもっと堅牢なことをしてくれることを期待しています。
DLLを作成する必要があるようです。 JMPは、単一のパラメーターを持つものでうまく機能します。 その引数はあなたの文字列である可能性があります。
あなたはこのようなことをすることができます。 これが(私の初めての、多かれ少なかれ)PowerShellスクリプトです(githubとスタックオーバーフローに感謝します!)デスクトップファイルへのパスを修正します...
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
これがデスクトップ用のJSLスクリプトpstest.jslです...
s=socket();
s<<CONNECT></CONNECT>
これは必須だったと思いますが、2、3回の誤った開始の後は確信が持てません...
Dialog from windows to allow PowerShell to open a port.Dialog from windows to allow PowerShell to open a port.PowerShellがポートを開くことができるようにするためのWindowsからのダイアログ。
そして最終的には
Right-click the .PS1 script on the desktop and ->Run in PowerShell.Right-click the .PS1 script on the desktop and ->Run in PowerShell.デスクトップで.PS1スクリプトを右クリックし、-> PowerShellで実行します。