Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell program with username and password Post 302398712 by thedemonhunter on Thursday 25th of February 2010 02:02:27 PM
Old 02-25-2010
vivekraj, you seem to understand what i need to do. I attempted something similar but i was having trouble comparing the two (username and password). What if i wanted to do this for multiple users? Would i use a CASE statement? such as:

Code:
case $username in
    alex ) pass=alex2;;
    sean ) pass=sean2;;
    ashley ) pass=ashley2;;
    # *) echo "error"
esac

But then i'm thinking this would affect the whole code and you would need the names as such: alex | sean | ashley.

What do you guys think?

---------- Post updated at 11:35 AM ---------- Previous update was at 10:51 AM ----------

also guys, this is what i had so far. i know it's wrong (especially the * part, it doesn't work) but like i said i am very new to this. i was trying to do this for one user first but i actually want to do multiple like i mentioned.

Code:
#!/bin/sh

echo "Enter login name and password"
read trythis

if [ $trythis = "Aarin_dtfc" ]
then
	echo "You are logged in!"
else [ $trythis = "Aarin_*" ]
	echo "Wrong password!"
	exit 1
else [ $trythis = "*_dtfc" ]
	echo "Login name is not recognized!"
	exit 2
fi
exit 0



---------- Post updated at 02:02 PM ---------- Previous update was at 11:35 AM ----------

ok i rewrote the code to this:

Code:
#!/bin/sh
echo "Enter username"
read username
if [ $username = "Aarin" ]
then  
 echo Enter password
 read password
case $username in
 Aarin ) pass=dtfc;;
 Rick ) pass=unpo
esac
while [ "$password" != "$pass" ]; do
 echo "Wrong password!"
 return 1
done
echo "You are logged in!" 
return 0
else
 echo "Login name not recognized"
fi
return 2

the only thing i am having trouble doing is adding multiple usernames to the if statement

Last edited by pludi; 02-25-2010 at 04:17 PM.. Reason: Please use code tags.......
 

10 More Discussions You Might Find Interesting

1. Programming

getting username from a c program in unix

How to get the user name of the Operating system from a c program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (3 Replies)
Discussion started by: Rajeshsu
3 Replies

2. Shell Programming and Scripting

username password in script

Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script?? something like ssh a@b -p password ??? (5 Replies)
Discussion started by: roshanjain2
5 Replies

3. Shell Programming and Scripting

Read Oracle Username password SID from single file and pass it to shell

Dear All I am trying to write one shell which will be running through Cron which contain one SQL query. But I want to draw/fetch the Username password and Instance name (required to loging to the database) from one single file to run that SQL query . Also this file contain details of multiple... (2 Replies)
Discussion started by: jhon
2 Replies

4. UNIX for Dummies Questions & Answers

How can i hide username/password

hi all, i run sqlplus command on unix(HP-UX) like "sqlplus username/password@serverA @deneme.sql" but when someone run "ps -ef | grep sqlplus", it can see my username and password :( How can i hide username and password. thanx. (1 Reply)
Discussion started by: temhem
1 Replies

5. UNIX for Advanced & Expert Users

Login through SFTP using username and password

Hi All, I want to login to a server through SFTP by giving username and password, in an automated script. I know that this can be done through public key authentication, but my requirement is to login ONLY through username and password. I am using GNU/Linux server. Please advise me !!!... (4 Replies)
Discussion started by: sparks
4 Replies

6. Shell Programming and Scripting

Asking username and password in the middle of the Shell/perl script

Can any body help me to find out the logic I have a script chkcomponent.pl Which give some output Like component1 userid: u1 component2 userid: u2 component3 userid: u1 . . #The no of components are different in different times run Now I want this chkcomponent.pl script... (1 Reply)
Discussion started by: pareshpatra
1 Replies

7. Shell Programming and Scripting

Username and password

Hi I am new to using unix and am struggling with a script i am writing. What i am trying to do is get a user to enter a username, check the original file i created with username and pin to see if their is a corresponding entry. Next ask the user to enter the pin and see if this matches... (5 Replies)
Discussion started by: somersetdan
5 Replies

8. UNIX for Dummies Questions & Answers

How do you reset username/password

Picked up a 3b2 running System V. Works fine, but it requires a username and password. Is the username "root" or "sysadm"? How do I find out and how to I reset it or bypass it? Thanks. (2 Replies)
Discussion started by: TanRuNomad
2 Replies

9. Programming

Getting username from an informix 4gl program in UNIX

How to get the user name of the Operating system from an Informix 4gl program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (0 Replies)
Discussion started by: enriquegm82
0 Replies

10. Shell Programming and Scripting

Passing Username & password through shell script to java code

Hi, I have a shell script (script.sh) in which we are calling java code which asks for Username: Password: for authentication purpose currently we are passing the credential manually and run the script. but I am trying echo -e "user_id\npassword" | script.sh but its not... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies
asadmin-list-connector-connection-pools(1AS)			   User Commands		      asadmin-list-connector-connection-pools(1AS)

NAME
asadmin-list-connector-connection-pools, list-connector-connection-pools - gets all the connection pools SYNOPSIS
list-connector-connection-pools --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure |-s] [--password- file filename] [--terse=false] [--echo=false] [--interactive=true] gets all the connector connection pools. This command is supported in remote mode only. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. --interactive if set to true (default), only the required password options are prompted. Example 1: Using list-connector-connection-pools asadmin> list-connector-connection-pools --user admin --password adminadmin EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-connector-connection-pool(1AS), asadmin-delete-connector-connection-pool(1AS) J2EE 1.4 SDK March 2004 asadmin-list-connector-connection-pools(1AS)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy