微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从cygwin运行时如何结束Powershell脚本

如何解决从cygwin运行时如何结束Powershell脚本

|| 我有一个Powershell .ps脚本,该脚本在Windows计算机中执行一些基本的工作。我通过ssh-ing到Windows计算机来调用此脚本。 Windows计算机上安装了cygwin Open-SSh。 问题:脚本已执行,但不返回SSH会话。 如何使powershell脚本结束并将控制权返回给SSH会话?     

解决方法

        尼斯和简单的解决方案在这里: https://serverfault.com/questions/266535/how-to-run-a-powershell-script-from-cygwin-ssh-session#comment277301_266699 回声\“ \\ n \” | powershell .... etc .....     ,        回答可能有点晚,但是在安装cygwin sshd以从Linux Web服务器在citrix服务器上运行powershell命令之后,我们遇到了类似的问题。 我们最终落在此页面上: http://epeleg.blogspot.com/2010/06/solution-to-powershell-never-exists.html 这促使我们使用其中的powershell命令以及以下语法创建一个批处理文件:
%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Noninteractive -Command \"& { \"your powershell script and arguments here\" }\"<NUL
我们只运行批处理文件,而不是直接调用powershell,如果批处理文件中需要一个变量,则将%1用作变量。 最后的
my ($stdout,$stderr) = Net::SSH->new( \"user@host\" )->capture2( { timeout => $timeout },\"powershell -file $copied_ps1_file<NUL\");
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。