0

I am using laravel for my whois domain search. But when i use exec command in my controller, there is no output

My controller

<?php

    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\DB;
    use Illuminate\Support\Facades\Hash;
    use App\Models\User;
    
    
    class SorgulaController extends Controller
    {
        //
       
    
         //
         function sorgula (Request $req)
         {   
        $domain = $req->get('domain');
       
    
        return view('results', compact( 'domain' , ));
    
    
             
         }
    }
    
    ?>

My form blade

<form action="/tr/sonuc" method="post">,
            @csrf
                                <div class="form-group">
                                    <input  type="text" name="domain" 
                                    class="form-control form-control-lg" value=""
                                    placeholder="" required>
                                </div>
                                
                                
                                
                                <br>
                               
                                
                                <button type="submit" class="btn btn-outline-dark d-grid gap-2 col-3 mx-auto">Sorgula</button>
    
                                <br>
                                <p class="text-center"> <a class="text-primary" href="https://domaintelekom.com/login">oturum açın.</a></p>

                            </form>

My result blade

    <?php 
exec("whois $domain" , $data);

echo "<pre>";
print_r($data);

echo "</pre>";
?>

My route

       Route::get('/tr', function () {     
        return view('index');
    });
    
    Route::get('/tr/sonuc', function () {     
        return view('results');
    });
Route::post('/tr/sonuc',    [App\Http\Controllers\SorgulaController::class, 'sorgula']);

This is the result i got

This is the result i go

When i use vanilla php there are domain records. But there is no record when i use Laravel. Why is that?

Emre
  • 35
  • 7

2 Answers2

0

I was successful when using process on laravel

<?php
use Symfony\Component\Process\Process;
    
...

$current = new Process('whois google.com');
$current->run();

if (!$current->isSuccessful()) {
  // throw new ProcessFailedException($current);
}
$current = $current->getOutput();
0

I just found the answer the reason why my shell_exec or exec command doesnt work, it beacuse in my Centos panel there is no 43 port number. When i open port 43 it worked. Just add port number 43 and restart the firewall, it will work after that. Thanks for the answers.

Emre
  • 35
  • 7