Execute e edite um script Perl/Python/não Powershell no Powershell_ISE (Windows Server)

Execute e edite um script Perl/Python/não Powershell no Powershell_ISE (Windows Server)

Estou em um Windows Server (2012) com Powershell_ISE e antes de instalar software adicional queria editar e testar um script no Powershell_ISE (é uma opção melhornativosolução do que usar notepad + cmd.exe por causa da edição com guias, por exemplo)

Idéia: Atalho de teclado para uma entrada de menu (em "Complementos" no menu) onde operl.exeé chamado com o caminho do script atual como parâmetro.

Eu tentei as seguintes linhas:

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Perl",{$cur=$psISE.CurrentFile; saps "c:\strawberry\perl\bin\perl.exe" $cur.FullPath },'Ctrl+Alt+q')

(com saps=start-process) ou

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Perl",{$cur=$psISE.CurrentFile; & "c:\strawberry\perl\bin\perl.exe" $cur.FullPath },'Ctrl+Alt+e')

(com & = executar comando externo) ou

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Perl",{$cur=$psISE.CurrentFile; saps "c:\strawberry\perl\bin\perl.exe" $cur.FullPath -wait },'Ctrl+Alt+w')

(iniciar processo e esperar)

Uma janela cmd está piscando brevemente, mas no painel do console não há saída. (o Perlscript apenas imprime "teste" e está funcionando quando executado diretamente executando: & "c:\strawberry\perl\bin\perl.exe" $cur.FullPathno painel do console)

Se isso funcionar, você pode adicionar esta linha ao $profile do Powersehll_ISE para editar/executar scripts de todos os idiomas chamando o binário apropriado

Responder1

Um minuto depois, tentei a seguinte linha (com &em combinação com -waite funciona:

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Perl-Menu_Entry",{$cur=$psISE.CurrentFile; & "c:\strawberry\perl\bin\perl.exe" $cur.FullPath -wait },'Ctrl+Alt+y') 

(você também pode usar as teclas "F" - por exemplo: em vez de 'ctrl+alt+y', basta usar 'F4')

Para salvar o arquivo antes de executar adicione $psise.CurrentFile.Save()à linha:

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Perl-Menu_Entry",{$psise.CurrentFile.Save(); $cur=$psISE.CurrentFile; & "c:\strawberry\perl\bin\perl.exe" $cur.FullPath -wait },'Ctrl+Alt+y') 

informação relacionada