Unix/Linux Go Back    


Web Programming Discuss Web Programming and Web Server Administration, including LAMP, Apache, MySQL, HTML, SEO, and other Web APIs and topics.

Login page in html on unix

Web Programming


Tags
apache2, html, unix

Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 05-08-2009   -   Original Discussion by ravi18s
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
Take this simple script:
Code:
#!/bin/bash
echo -e "Content-Type: text/plain\n\n"
env
echo "-------------"
id

Put it in your servers /cgi-bin/ directory as minimal.sh, make it executable, and then call it from your browser as http://localhost/cgi-bin/minimal.sh?a=b&c=d&e=ü
Example output:
Code:
SERVER_SIGNATURE=<address>Apache/2.2.4 (Linux/SUSE) Server at localhost Port 80</address>

HTTP_KEEP_ALIVE=300
HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.5) Gecko/2008121300 SUSE/3.0.5-2.3 Firefox/3.0.5
SERVER_PORT=80
HTTP_HOST=localhost
DOCUMENT_ROOT=/srv/www/htdocs
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
SCRIPT_FILENAME=/srv/www/cgi-bin/minimal.sh
REQUEST_URI=/cgi-bin/minimal.sh?a=b&c=d&e=%C3%BC
SCRIPT_NAME=/cgi-bin/minimal.sh
HTTP_CONNECTION=keep-alive
REMOTE_PORT=50421
PATH=/usr/sbin:/bin:/usr/bin:/sbin
PWD=/srv/www/cgi-bin
SERVER_ADMIN=[no address given]
HTTP_ACCEPT_LANGUAGE=de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
REMOTE_ADDR=127.0.0.1
SHLVL=1
SERVER_NAME=localhost
SERVER_SOFTWARE=Apache/2.2.4 (Linux/SUSE)
QUERY_STRING=a=b&c=d&e=%C3%BC
SERVER_ADDR=127.0.0.1
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
HTTP_CACHE_CONTROL=max-age=0
HTTP_ACCEPT_ENCODING=gzip,deflate
REQUEST_METHOD=GET
_=/usr/bin/env
-------------
uid=30(wwwrun) gid=8(www) groups=8(www)

Notice the part in blue? That are the parameters for the script. The part in red? The Unicode codepoint for ü, as it was sent by my browser. If you really want to code this in bash, there are no libraries or other helpers for that kind of stuff. And you're not even tracking sessions yet.

What you'd have to do is code the login logic, authentication, authorization, and since the users should be able to run scripts, some kind of security lest you want to lose data.
Sponsored Links
    #9  
Old Unix and Linux 05-11-2009   -   Original Discussion by ravi18s
ravi18s's Unix or Linux Image
ravi18s ravi18s is offline
Registered User
 
Join Date: Mar 2009
Last Activity: 26 May 2009, 8:56 AM EDT
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Dear Pludi, Thanks for the code. But the problem is somewhat different and I already know how get or post works and how to run the scripts.
So let me explain you in a different manner. I dont want to use JSP and want to implement in html.

Lets take one example.... I have two html pages... first one is a login page through which a user will be able to login and then only will be able to see the second html page... and noone can able to directly access the second page without loging in... The problem is the login page that I want to design in such a way that it will give freedom to the user to change its password... and how I can use session in html pages..... Thanks and hope this time you can understand my problem more clearly
Sponsored Links
    #10  
Old Unix and Linux 05-11-2009   -   Original Discussion by ravi18s
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
Authentication: not possible with plain HTML
Authorization: not possible with plain HTML
User administration (including changing passwords): not possible in plain HTML
Sessions: not possible with plain HTML

For all 4 you'll have to at least code something up in JavaScript, or call any CGI backend (Shell, C, JSP, PHP, Perl, ...)
    #11  
Old Unix and Linux 07-20-2009   -   Original Discussion by ravi18s
jyoung's Unix or Linux Image
jyoung jyoung is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 26 November 2016, 7:52 PM EST
Location: Flint, MI
Posts: 262
Thanks: 0
Thanked 4 Times in 4 Posts
Hi Pludi,
Can you provide some links on how to code a CGI to run from an HTML page or how to call it? I tried yours, but it does not work as I get the error:

Code:
[Mon Jul 20 12:44:22 2009] [error] (8)Exec format error: exec of '/lsf1/IBM/IHS/cgi-bin/minimal.sh' failed
[Mon Jul 20 12:44:22 2009] [error] [client 000.00.00.00] Premature end of script headers: minimal.sh

I am sure it is something stupid that I am or am not doing. Thank you.
Sponsored Links
    #12  
Old Unix and Linux 07-20-2009   -   Original Discussion by ravi18s
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
Does Apache know that /lsf1/IBM/IHS/cgi-bin/ is a valid CGI directory? May the user Apache is running as run the script (eXecutable bit set)? Is /bin/bash a valid interpreter on your machine. Did you know that within 2 months you could probably have learned all the Perl/PHP that's needed for your task, plus some?
Sponsored Links
    #13  
Old Unix and Linux 07-21-2009   -   Original Discussion by ravi18s
jyoung's Unix or Linux Image
jyoung jyoung is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 26 November 2016, 7:52 PM EST
Location: Flint, MI
Posts: 262
Thanks: 0
Thanked 4 Times in 4 Posts
Hi Pludi,
Yes that is the valid CGI directory and the user can run the scripts. I removed the reference to bash as we use ksh. When I run the script from the unix command line it works. I had only found the link yesterday and thought if you had some links to running Perl or ksh scripts from a web page I could do the rest myself. Thank you for your response.

---------- Post updated at 10:17 AM ---------- Previous update was at 07:52 AM ----------

Hi Pludi,
Wanted to let you know that it worked once I changed the content type to text/html and added the line
Code:
#!/bin/sh

Again, thank you for your help.
Sponsored Links
    #14  
Old Unix and Linux 07-21-2009   -   Original Discussion by ravi18s
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
Argh, head, meet desk. Sorry for lashing out with my last question, shouldn't answer questions when sleepy.

As for your problem, the type of text/plain shouldn't affect execution in any way.

The shebang line (the one starting with #!) should look like one of the following:
  • for Bourne/POSIX-Shell compatible shells: #!/bin/sh
  • for Korn-Shell (ksh): #!/usr/bin/ksh
  • for Bo(u)rne-Again-Shell (bash): #!/bin/bash or #!/usr/bin/bash
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
APACHE: Tie in Web Page login with server login WhotheWhat Security 1 11-26-2008 02:58 AM
APACHE: Tie in Web Page login with server login WhotheWhat Web Programming 2 11-19-2008 11:17 AM
Html web page to Unix Connectivity abhilashnair UNIX and Linux Applications 1 03-06-2008 10:13 AM
linking unix generated text file to html page alexd Shell Programming and Scripting 1 11-13-2002 12:21 PM
Unix Manual (man-page) pages in HTML killerserv News, Links, Events and Announcements 1 06-26-2002 01:05 AM



All times are GMT -4. The time now is 02:53 AM.