Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Using PHP to view syslog in private web page Post 303036827 by Neo on Friday 12th of July 2019 11:15:26 PM
Old 07-13-2019
Generally in PHP you are better off with a simple shell_exec() command and then process the results in PHP.

For example, from the above code, you could do this:

Code:
<?php
$command = "tail -n 11 /var/log/_gateway-syslog.log");
$raw_output = shell_exec($command);
$output = process_output($raw_output):
echo "<pre>$output</pre>";

function  process_output($text)
{
  // do your text processing here instead of using a shell command pipeline in shell_exec()
 return $processed_text;
}

PHP has rich tools for text processing including regular expressions.

I written these types of PHP files to display unix / linux system information countless times, and I always process the text in PHP without exception.

In general, I find it best to decouple the "shell exec" type of commands from PHP as much as possible for a number of reasons, including system security, integrity and long-term system maintenance.

For a real-world example on this web site, we use shell_exec() to begin processing all the man pages in our man page repository; but the shell_exec() only returns the raw output from the man command. Then the PHP script extensively processes the raw man page output, adding links, formatting, html entities, css information, etc. There is a significant amount of text processing done in PHP, but the PHP shell_exec() command to get the man page from the Linux filesystem and output for processing is very basic / simple.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Web page hosting

I built my website based on Dreamweaver, on Windows platform. My server uses Unix, and the page doesn't look too good. Is there any way to solve this problem without too much of a headache? (1 Reply)
Discussion started by: PCL
1 Replies

2. UNIX for Dummies Questions & Answers

view page command?

Hi All, When I run a command on any shell, many times the output is longer than the screen can hold, so I only can see parts of the output. Is there a command that will show me page by page the results of each command? Thanks, Jared (3 Replies)
Discussion started by: JaredsNew
3 Replies

3. Shell Programming and Scripting

View an html page inside zenity

Hi! :) Inside a bash script, I have an html page: "example.html" I need: - read "example.html. - print and view the result for example with dillo (or another light browser) inside zenity with clickable images and links. Some stuff like: zenity --html-info --filename=example.html Is... (0 Replies)
Discussion started by: aspire
0 Replies

4. Web Development

web interface to view,copy,select files

Hi. I have been working on an email backup solution. I need some kind of web admin interface to view , copy & select files in order to restore them. Can someone point me to the right direction? Or do i need to code it from scratch. Something that need a little modification to work is OK. ... (3 Replies)
Discussion started by: coolatt
3 Replies

5. Programming

Need a help in automating the http authenticated web page - via PHP scripting

Hi all, Need a help in PHP scripting. Am automating a process in web page. The process is 1. i have to open that web page using the user credentials (Username and password). 2. select a drop down and click submit button. 3. Then check for the status of the page. Please help me how to... (1 Reply)
Discussion started by: vidhyaS
1 Replies

6. AIX

View OS version within HMC web GUI?

Hello there Im wondering is there any way to see lpar OS info (like 5.3 or 6.1) in HMC web GUI? Because in some situation, the lpar is inactive, the only way to check OS version is to activate, this process takes time :) Tks! (8 Replies)
Discussion started by: bsddaemon
8 Replies

7. Shell Programming and Scripting

Web page with picture, text, php function

Hello. I'm trying to create a web page which the presentation is as follows: 1 °) at the top of page an image 2 °) below the text 3 °) to complete a php function that returns information. I tried different things but none work. Script 1: <!DOCTYPE html> <html> <head> <style> div { ... (5 Replies)
Discussion started by: jcdole
5 Replies

8. UNIX for Dummies Questions & Answers

What is a page from Linux point of view ?

Versions : RHEL 6.xx /OL 6.xx I am trying to understand what a page is in Linux? The concept should be same in Unix as well, I guess The below doc says "A page is a block of virtual memory. A typical block size on Linux operating system is 4KB " ... (4 Replies)
Discussion started by: kraljic
4 Replies
PHP-FPM(8)							Scripting Language							PHP-FPM(8)

NAME
php-fpm - PHP FastCGI Process Manager 'PHP-FPM' SYNOPSIS
php-fpm [options] DESCRIPTION
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to /var/log/php-fpm.log. Most options are set in the configuration file. The configuration file is /etc/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for '.php' files to port 9000 and you should edit your webserver configuration file appropriately. OPTIONS
-C Do not chdir to the script's directory --php-ini path|file -c path|file Look for php.ini file in the directory path or use the specified file --no-php-ini -n No php.ini file will be used --define foo[=bar] -d foo[=bar] Define INI entry foo with value bar -e Generate extended information for debugger/profiler --help -h This help --info -i PHP information and configuration --modules -m Show compiled in modules --version -v Version number --prefix path -p Specify alternative prefix path (the default is /usr) --fpm-config file -y Specify alternative path to FastCGI process manager configuration file (the default is /etc/php-fpm.conf) --test -t Test FPM configuration file and exit If called twice (-tt), the configuration is dumped before exiting. --zend-extension file -z file Load Zend extension file FILES
php-fpm.conf The configuration file for the php-fpm daemon. php.ini The standard php configuration file. SIGNAL
Once started, php-fpm then responds to several POSIX signals: SIGINT,SIGTERM immediate termination SIGQUIT graceful stop SIGUSR1 re-open log file SIGUSR2 graceful reload of all workers + reload of fpm conf/binary SEE ALSO
The PHP-FPM website: http://php-fpm.org For a more or less complete description of PHP look here: http://www.php.net/manual/ A nice introduction to PHP by Stig Bakken can be found here: http://www.zend.com/zend/art/intro.php BUGS
You can view the list of known bugs or report any new bug you found at: http://bugs.php.net AUTHORS
PHP-FPM SAPI was written by Andrei Nigmatulin. The mailing-lists are highload-php-en (English) and highload-php-ru (Russian). The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski. A List of active developers can be found here: http://www.php.net/credits.php And last but not least PHP was developed with the help of a huge amount of contributors all around the world. VERSION INFORMATION
This manpage describes php-fpm, version 5.4.4-14+deb7u14. COPYRIGHT
Copyright (C) 1997-2009 The PHP Group Copyright (c) 2007-2009, Andrei Nigmatulin This source file is subject to version 3.01 of the PHP license, that is bundled with this package in the file LICENSE, and is available through the world-wide-web at the following url: http://www.php.net/license/3_01.txt If you did not receive a copy of the PHP license and are unable to obtain it through the world-wide-web, please send a note to license@php.net so we can mail you a copy immediately. The PHP Group 2009 PHP-FPM(8)
All times are GMT -4. The time now is 04:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy