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>
이것이 필수라고 생각하지만 몇 번의 잘못된 시작 후에는 확신할 수 없습니다...
PowerShell이 포트를 열 수 있도록 하는 Windows의 대화 상자.
그리고 결국
바탕 화면에서 .PS1 스크립트를 마우스 오른쪽 버튼으로 클릭하고 -> PowerShell에서 실행합니다.