【问题标题】:Use plink/ssh in a Batch批量使用 plink/ssh
【发布时间】:2018-03-27 00:58:49
【问题描述】:

我尝试使用 plink 从本地计算机连接到服务器。我需要从服务器通过 ssh 连接到其他本地 mashine 以执行一些命令

我的尝试是:

plink -load "puttyProfile" -pw password "ssh admin@address"

有效。但是现在我想给 ssh 一个这样的操作

plink -load "puttyProfile" -pw password "ssh admin@address "cd .."   "

我的错误看起来很奇怪,像这样

#< CLIXML <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" .... 

持续了一段时间。 请给点建议=D 问候

【问题讨论】:

  • 你的错误是Powershell,但你使用了batch-file标签。
  • 从哪里执行plink 命令行?
  • 对不起,我不认为它会有所作为。 plink 是控制台的腻子应用程序。在 Linux 上和 ssh 一样工作

标签: shell batch-file ssh putty plink


【解决方案1】:

好吧,我自己搞定了.. 在我想要执行操作的最后一台电脑上,ssh 使用的是 powershell 而不是命令提示符。似乎 powershell 无法使用通过 ssh 给出的操作列表。我改为命令提示符,它工作得更好。 我还需要将内部“更改为” 当你使用 && 时,链接命令不是问题;不会工作

ssh admin@address "ssh admin2@address2 'cd ..  &&  dir'  ; echo hey "

【讨论】:

    【解决方案2】:
    "C:\\Program Files\\PuTTY\\plink.exe" -ssh "10.164.107.11" -l "karan" -pw "3Wdgwqd@Ws" -m "command.txt"
    

    在您可以编写的命令中:

    cd / ;
    cd /local/apps/coreservices-s3/;
    echo -e "The file is present in\n ";
    
    find . -type f -name "TextFile4*";
    
    echo -e "The content of the file is :\n ";
    find . -name "vccvdv6.txt" |xargs cat
    
    echo -e "\n\n."
    

    【讨论】:

      猜你喜欢
      • 2011-12-25
      • 2017-04-13
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 2019-02-24
      相关资源
      最近更新 更多