SSH 错误:名称或服务未知

发布于 2025-01-06 22:35:25 字数 221 浏览 0 评论 0原文

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

PS:我正在编写 ruby​​ 脚本 帮我解决一下,

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

I am getting this error because, there are 5 peripheral trays on 10 available slots(subjected to change at anytime) so i have no other option other than pinging all of them and performing a command(killall). Is there a way to disable viewing this error and just performing the operation if the tray is available and ignore other wise

PS: am writing ruby script
help me out

code goes like this
for i loop
ssh -f -n user@host_$i killall -9 process

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

电影里的梦 2025-01-13 22:35:25

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

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

Will this be a workable solution?? Added your code into a Exception handling block and not doing anything in the handle.

for i loop
Begin 
    ssh -f -n user@host_$i killall -9 process
Ensure Exception =>e
   //Forget about logging anything
End
蓬勃野心 2025-01-13 22:35:25

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

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

Curious if this block solves the problem, not a great solution , but tried to refine on the exception one ...

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文