Posted on October 12, 2018 at 12:59 pm
With PHP you can use shell_exec() to execute a command via shell and return the complete output as a string, here si a quick example to do so:
$output = shell_exec('ls -lart');
However some commands like “gunzip -t” may show empty results.
To fix that, just add 2>&1 to the end of the command, i.e:
echo shell_exec("gunzip -c -t /path/to/file.gz 2>&1");
The issue was a line break at the beginning of the gunzip output.
Thanks to Trev for this smart tip!
- View All Symlinks in a Directory Tree on Linux
- /etc/init.d/redis-server on Debian 9.5 Stretch
- View Last Time a File was Opened on Debian
- Fix PHP7.0-FPM Installation (Sury.org Packages)
- Server Certificate Verification failed CAfile (apt-get update)
- PDFYeah: Online Cloud-Based PDF Converter
- Create a SOCKS 5 Proxy on Top of a SSH Tunnel on Linux
- Estimate Number of Visitors and Pageviews of any Website
- Htaccess file for WordPress websites
- How to Create Backups of MySQL via PHP
- Transfer files from a VPS to a FTP web hosting server
- Block Paltalk Ads (and Others) via Hosts file
- E: Sub-process /usr/bin/dpkg returned an error code (2)
- How to Validate JSON in PHP
- The program can’t start because VCRUNTIME140.DLL is missing
- PHP CURL Download Remote URL to File