php - I am unable to handle SSH Connection Error Anyway -
i'm trying handle runtimeexception connect vps through ssh.
here's code connect vps through ssh.
$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...";   it's written in laravel. in case, if error ssh connection, should redirect me view named add_server. but, i'm getting exception instead of redirection. here's errror every time instead of redirection.
what want is, if there error connection vps through ssh, should redirect me view named add_server
let me know what's wrong code.
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'); }      
Comments
Post a Comment