You need to watch your quotes and escaping. In PHP this is all one big double-quoted section, and any double quotes inside it must be escaped so they don't end early.
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
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:
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.
Corona688, Thank you. That was the quick fix and it worked....
Neo,
Thank you, I like your idea and I have followed the logic in your suggestion. However I am lost when it gets to processed_output. everything I have tried gives me no output.
I even replaced the tail -n with just cat to make sure I would see something. under the function process_output I ran a simple test using a grep for 20.254 . I'm seeing nothing.
Quote:
Originally Posted by Corona688
You need to watch your quotes and escaping. In PHP this is all one big double-quoted section, and any double quotes inside it must be escaped so they don't end early.
Quote:
Originally Posted by Neo
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:
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.
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)
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)
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)
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)
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)
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)
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)
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)