Anyway to run sudo command and getting output?

Posted 1 year ago by Shirshak

In ubuntu I can get the networking traffic details via

$ sudo iftop -t -s 1 -L 10

which gives result like this

interface: eth0
IP address is:
MAC address is: c0:3f:d5:f6:cb:d3
Listening on eth0
   # Host name (port/service if enabled)            last 2s   last 10s   last 40s cumulative
   1                          =>      128Kb      128Kb      128Kb     31.9KB                              <=     10.0Mb     10.0Mb     10.0Mb     2.50MB
   2                            =>      163Kb      163Kb      163Kb     40.9KB                          <=     8.08Mb     8.08Mb     8.08Mb     2.02MB
   3                          =>      342Kb      342Kb      342Kb     85.5KB                             <=     6.38Mb     6.38Mb     6.38Mb     1.60MB
   4                           =>     81.0Kb     81.0Kb     81.0Kb     20.2KB                              <=     5.07Mb     5.07Mb     5.07Mb     1.27MB
   5                           =>     78.7Kb     78.7Kb     78.7Kb     19.7KB                              <=     5.06Mb     5.06Mb     5.06Mb     1.26MB
   6                           =>     55.2Kb     55.2Kb     55.2Kb     13.8KB                            <=     3.36Mb     3.36Mb     3.36Mb      859KB
   7                           =>     52.5Kb     52.5Kb     52.5Kb     13.1KB                              <=     3.05Mb     3.05Mb     3.05Mb      781KB
   8                           =>     58.0Kb     58.0Kb     58.0Kb     14.5KB                              <=     2.62Mb     2.62Mb     2.62Mb      671KB
   9                          =>     74.1Kb     74.1Kb     74.1Kb     18.5KB                          <=     2.23Mb     2.23Mb     2.23Mb      571KB
  10                           =>     47.5Kb     47.5Kb     47.5Kb     11.9KB                              <=     1.90Mb     1.90Mb     1.90Mb      487KB
Total send rate:                                     3.01Mb     3.01Mb     3.01Mb
Total receive rate:                                  67.7Mb     67.7Mb     67.7Mb
Total send and receive rate:                         70.7Mb     70.7Mb     70.7Mb
Peak rate (sent/received/total):                     3.01Mb     67.7Mb     70.7Mb
Cumulative (sent/received/total):                     771KB     16.9MB     17.7MB

But we know we used sudo there. I am working for page in university where i can show this result interactivly probably on charts. But I cannot get the output as it need sudo command .

I made command like this

$ php artisan university:internet 

Which in turn calls that sudo command

I know it will give permissions error? Any way or hack to make it possible?


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.