Wednesday 28 November 2012

creating HTML page using Shell script

following is the script to create a html page, copy and paste in a document and save it as test.sh

#!/bin/bash

# make_page - A script to produce an HTML file
name=$(logname)
uname=$(uname)
time=$(date +"%x %r %z")
uptime=$(uptime)
function system_info
{
echo "$uptime is the new uptime"
}
cat << EOF
<HTML>
<HEAD>
    <TITLE>
    mysql check
    </TITLE>
</HEAD>

<BODY>
    $system_info <br>
    welcome $name on $uname at $time
    <h1>This checks the mysql conection</h1>
  <form>
    <h3>Enter the mysql username<input type="text" name="name"></h3>
    <h3>Enter the password<input type="password" name="pwd"></h3>
    <input type="submit" value="submit">
  </form>

</BODY>
</HTML>
EOF


-----------------------------------------------------------------------------------------------

Then in order to run it on the browser create another script, m.sh and copy paste the content below in it:

sh test.sh > r.html
gnome-open "r.html"

-----------------------------------------------------------------------------------------------

In order to run it, just run the latest shellscript- m.sh, just type the following in the terminal


sh m.sh



and the browser automatically opens the crested html file.

No comments:

Post a Comment