【问题标题】:SSH error : name or service not knownSSH 错误:名称或服务未知
【发布时间】:2012-02-17 21:55:15
【问题描述】:

我收到此错误是因为 10 个可用插槽上有 5 个外围托盘(随时可能更改),所以除了 ping 所有这些插槽并执行命令(killall)之外,我别无选择。有没有办法禁用查看此错误并仅在托盘可用时执行操作而忽略其他方式

PS:我正在编写 ruby​​ 脚本 帮帮我

代码是这样的
for i 循环
ssh -f -n user@host_$i killall -9 进程

【问题讨论】:

  • 你能提供更多细节吗?你在 SSH 什么?
  • @blueberryfields 代码如下 for i loop ssh -f -n user@host_$i killall -9 process

标签: ruby ssh


【解决方案1】:

这是一个可行的解决方案吗?将您的代码添加到异常处理块中,并且在句柄中不做任何事情。

for i loop
Begin 
    ssh -f -n user@host_$i killall -9 process
Ensure Exception =>e
   //Forget about logging anything
End

【讨论】:

  • 异常不会导致循环停止运行吗?
【解决方案2】:

很好奇这个块是否解决了问题,不是一个很好的解决方案,但试图改进异常...

killports = 0
killedcount=false
if (killedcount===false)
  while killports <= 10
begin
  puts killports
  killports=killports+1
  killedcount=true
  ssh -f -n user@host_$i killall -9 process    rescue Exception =>e
  puts "Comming to an exception"
  if killports<=10 && killedcount===true then
    killedcount=false
    retry
  else
    raise
  end
end
killedcount=false
end
end

【讨论】:

    猜你喜欢
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 2016-11-10
    相关资源
    最近更新 更多