linux脚本不能执行rm,Python Winrm无法执行长幂shell脚本

我正在使用linux python winrm模块在远程windows机器上使用“run_ps”从linux机器运行powershell脚本。在

对于较小的脚本,它可以正常工作,但如果传递太长的powershell代码,则无法执行。在

“run_ps”方法有以下代码。在def run_ps(self, script):

"""base64 encodes a Powershell script and executes the powershell

encoded script command

"""

# must use utf16 little endian on windows

base64_script = base64.b64encode(script.encode("utf_16_le"))

rs = self.run_cmd("powershell -encodedcommand %s" % (base64_script))

if len(rs.std_err):

# if there was an error message, clean it it up and make it human

# readable

rs.std_err = self.clean_error_msg(rs.std_err)

return rs

我想可能是“utf_16_le”编码问题或字节大小问题,但不确定。我试过使用“utf_32_le”,但没有结果。在

我使用python2.6.6运行CentOS版本6.2(Final)中的脚本。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值