Operating System - HP-UX
1821187 Members
3200 Online
109631 Solutions
New Discussion юеВ

Re: how to embedded Unix command in html

 
ashan
Advisor

how to embedded Unix command in html

Hi,

I try create simple html file to list running
process put I can see the command ps -ef only

I may doing wrong ....need your Advice.

Regards

Ashan

my html file looks like..



TEST in uxadmin<BR />


ps -ef


5 REPLIES 5
Tor-Arne Nostdal
Trusted Contributor

Re: how to embedded Unix command in html

A Unix command (or any operating system command) would not directly be processed on the server just by putting it into an HTML-file.

The HTML-code is just a flat file stored on your server, and this file is interpreted by your parser/browser. A command in the HTML-file would therefore be tried runned on your client, not on the server.

HTML="HyperText Markup Language" is using tags to specify "commands" to the parser. There is limited commands available and most of them is related to layout for presenting text.

In your example you are using the command that tells the parser to use the tag-enclosed text as a title for the browser window.<br /><br />The text "ps -ef" is enclosed in the <body> tag and treats the text as a text with no specific formatting, and just print it in the browser window.<br /><br />You can try to copy your code into Notepad on your PC. Then save the it to a file named C:\TEST.HTML<br />Start then a browser (ex. Internet Explorer, Netscape or Opera) and instead of a WEB-address (URL) you type in: file://C:\TEST.HTML<br /><br />You will see that you get a window with "TEST in uxadmin" as title, and the page will only contain the text "ps -ef"</body>
I'm trying to become President of the state I'm in...
Philippe MALINGE
New Member

Re: how to embedded Unix command in html

Html files are static.
But you can write a small shell script that generate html pages.

In your cgi-bin create the following shell script 'ps.cgi'
(warning : the empty line after text/html is mandatory):

#!/bin/sh

cat <Content-type: text/html


TEST in uxadmin<BR />



EOF

ps -ef

cat <



EOF

Hope this help.
--
Philippe
Fido
Tor-Arne Nostdal
Trusted Contributor

Re: how to embedded Unix command in html

Here is one way for how you can solve your problem. You should get the text2html.awk program and put it into your server (example in /usr/local/bin). This will help you format the output as a valid HTML-file.

1) Generate a WEB page with the process info
ps -ef | /usr/local/bin/text2html.awk > ./ps-overview.html

2) You code would then be something like this


TEST in uxadmin <BR />


To see ps -ef

[Click here]



Both your file and the ./ps-overview.html must be located in the same directory.

Some comments:
To get automatic updates of the prosess status you could f.ex.
- schedule a cronjob (limit to 1 min. updates)
- start an endless looping program which runs the command in intervals

If you still doesn't get the picture - I'll recommend a course in HTML coding.

P.S.
You submitted this message in a Forum for "Business Recovery Planning" perhaps you rather should search for assistance in HTML-coding.
I'm trying to become President of the state I'm in...
Tor-Arne Nostdal
Trusted Contributor

Re: how to embedded Unix command in html

After you have created the CGI file and placed it in your cgi-bin directory, you still must have your initial HTML file, and state like this:



TEST in uxadmin <BR />


To see ps -ef

[Click here]



NB! this could be harmful !!!
If you run prosesses that contains "secret" information in the command line (like username/password) you would not like everyone to see this...
By enabling anyone connecting to this system with a browser to see all running prosesses - you might reveal to much info.
I'm trying to become President of the state I'm in...
Francisco J. Soler
Honored Contributor

Re: how to embedded Unix command in html

Ha ahsan,
if your provider, support php you can try to make a dynamic web page.



TEST in uxadmin<BR />


.... HTML code here.

Your php code. Is a script code, you can do many things with it, even execute commands from O.S.
?>

..... more HTML code.



For more info check it out:

http://www.php.net

Frank.
Linux?. Yes, of course.