I need to inform a user and show if this user exists or not using Shell Script with CGI and Apache2

Asked

Viewed 54 times

0

#!/bin/bash

echo "content-type: text/html"
echo "
    <html> <head> <meta charset='utf-8' /> <title> Shell Script com CGI </title> </head>
    <body>
    <h1> Informações do usuário</h1>
"
echo ""
echo "<form>
        Digite o nome do usuário: <input type="text" name="nome">
        <input type="submit" value="Visualizar">
    </form>"

echo "<pre>Script executado: $0</pre>"
user="`echo $QUERY_STRING | awk -F= '{print $2}'`"

if [ ${user} = "" ] 
then
    echo "Usuário não encontrado!"
else
    echo "<pre>Informações do usuário: $(cat /etc/passwd | grep ${user})</pre>"
if
echo "<pre>Data e hora da consulta: $(/bin/date +%d-%m-%Y--%H:%M:%S)</pre>"

echo "
    </body>
    </html>
    "
  • 1

    Could you improve your question and code, please?

  • I rewrote the question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.