Reputation: 35434
As discussed here for PHP, we can redirect stdout to text file. I'm looking for similar way to redirect stdin to file too.
Though, my google search and search on our site results with little helpful. We can easily do that in Python as discussed here
Upvotes: 2
Views: 1129
Reputation: 179
Not sure if this is what you want... but you can read stdin like this:
$stdin = fopen('php://stdin', 'r');
$input = trim(fgets($stdin));
fclose($stdin);
file_put_contents('filename',$input);
Upvotes: 1