Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display php output on a txt file Linux command line

I currently have a blacklist.php file that generates a black list and I need a blacklist.txt file on Linux that pulls the output from the PHP file.

Is this possible?

like image 317
Andres Felipe Carvajal Avatar asked Mar 26 '13 04:03

Andres Felipe Carvajal


People also ask

How do you display the contents of a text file in PHP?

The file_get_contents function takes the name of the php file and reads the contents of the text file and displays it on the console. get the contents, and echo it out. <? php echo file_get_contents( "filename.

How do I view a PHP file in Linux?

Open Terminal using Ctrl + Alt + T , now type sudo -H gedit , then type your password and press enter . This will open the gEdit program with root permission. Now open your . php file where it's located or just drag the file into gEdit.

How do you display a text file in Linux terminal?

The simplest way to view text files in Linux is the cat command. It displays the complete contents in the command line without using inputs to scroll through it.


1 Answers

If your blacklist.php writes output to standard output, you can run your PHP script like this

php blacklist.php > blacklist.txt
like image 79
Litmus Avatar answered Oct 01 '22 09:10

Litmus