SSHを介してVPSに接続するためにRunTimeExceptionを処理しようとしています。私はSSH接続エラーを処理することができません
SSH経由でVPSに接続するコードは次のとおりです。
$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
という名前のビューにリダイレクトする必要があります。しかし、リダイレクトの代わりに例外が発生しています。リダイレクションの代わりに毎回得られるエラーです。私が欲しいもの
は、SSH経由VPSためにいくつかのエラー接続がある場合、それは私がコードで間違っているものを知ってみましょう
add_serverという名前を見るために私をリダイレクトする必要があり、です。
私はこのコードを試しました。それでも、リダイレクトなしで同じ例外が発生しています... –