开发者

Plink command is invalid to cmd.exe

I am trying to throw a plink command to my esx server and grep the linux output of the command. The code above does not work. But if I remove the | grep part it works again. Is there any other way to achieve the same results but making the command passable with cmd.exe?

FOR /F "TOKENS=1 DELIMS=:" %%A IN ('TYPE %SYSTEMDRIVE%\Users\Ian\Desktop\backup.list') DO ECHO %%A & (FOR /F "TOKENS=2*" %%B IN ('%PLINK% -batch -ssh %USERNAME%@%ESXHOST% -pw %PASSWORD% vim-cmd vmsvc/get.datastores %%A | grep datasto开发者_开发技巧re') DO ECHO %%B)


Just looking at it (without plink.exe to test with at the moment), the problem seems to be that the | is being interpreted by cmd.exe instead of being passed as part of the argument string to plink.exe.

If that guess is correct, it's an easy fix: just escape the | by putting a ^ in front of it, so that %%A | grep becomes %%A ^| grep.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜