Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php shell_exec() out put to get a text file

I'm trying to run rate -c 192.168.122.0/24 command on my Centos computer and write down the output of that command to the text file using shell_exec('rate -c 192.168.122.0/24') command; still no luck!!

like image 984
Roshan Wijesena Avatar asked Sep 16 '25 00:09

Roshan Wijesena


1 Answers

If you don't need PHP, you can just run that in the shell :

rate -c 192.168.122.0/24 > file.txt

If you have to run it from PHP :

shell_exec('rate -c 192.168.122.0/24 > file.txt');

The ">" character redirect the output of the command to a file.

like image 62
Matthieu Napoli Avatar answered Sep 17 '25 13:09

Matthieu Napoli