PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php-我仍然无法处理SSH连接错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试处理RunTimeException以通过SSH与VPS连接.

这是通过SSH与VPS连接的代码.

@H_403_6@$server_ip = Input::get('server_ip'); $password = Input::get('password'); $validator = Validator::make( ['server_ip' => $server_ip], ['server_ip' => 'ip|required|unique:servers'], ['password' => $password], ['password' => 'required|confirmed'] ); if(!$validator->fails()) { Config::set('remote.connections.production.host',$server_ip); Config::set('remote.connections.production.username','root'); Config::set('remote.connections.production.password',$password); Config::set('remote.connections.production.root','/'); $command = 'MysqL --version'; $connection_status = SSH::run($command, function($linE) { $this->output = $line.PHP_EOL; }); if(!$connection_status) return $this->output; else return view('dashboard.add_server'); } else return "Validation Failed...";

它写在Laravel中.以防万一,如果我在SSH连接时遇到错误,它应该将我重定向到名为add_server的视图.但是,我得到了异常而不是重定向.这是我每次都收到的Errror,而不是重定向.

php-我仍然无法处理SSH连接错误

我想要的是,如果通过SSH与VPS有一些错误连接,它应该将我重定向到名为add_server的视图

让我知道代码有什么问题.

解决方法:

@H_403_6@try { $connection_status = SSH::run($command, function($linE) { $this->output = $line.PHP_EOL; }); if(!$connection_status) return $this->output; } catch(\RunTimeException $E) { return view('dashboard.add_server'); }

大佬总结

以上是大佬教程为你收集整理的php-我仍然无法处理SSH连接错误全部内容,希望文章能够帮你解决php-我仍然无法处理SSH连接错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: