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?
If your blacklist.php writes output to standard output, you can run your PHP script like this
php blacklist.php > blacklist.txt
We can do it using file_put_contents
<?php
file_put_contents('blacklist.txt ', file_get_contents('blacklist.php'));
?>
Another alternative: Use exec()
<?php
exec ('php blacklist.php', $output);
file_put_contents('blacklist.txt', $output);
?>
Another alternative:Output redirection to a text file using Command line
In Windows:
C:\xampp\php>php C:\xampp\htdocs\blacklist.php >blacklist.txt
In Linux:
$ php blacklist.php >blacklist.txt
file_put_contents...