Sponsored Content
Top Forums Shell Programming and Scripting Case Statement for Login/Logoff Script Post 302622779 by bbowers on Thursday 12th of April 2012 03:31:29 PM
Old 04-12-2012
Case Statement for Login/Logoff Script

I'm currently trying to write a login script. I have already written a logoff script that uses an if/else statement.

Code:
#!/bin/bash
TIMED=$(date +%H)
if [ "${TIMED}" -lt "16" ]' then
  echo Have a Great Day $USER
else
  echo Have a Great Night $USER
fi

But I'd like to write one that give me the option of saying Good Afternoon $USER. I'm not quite sure how to write that in a case statement. Any ideas for me?
Thanks a bunch

Last edited by Scrutinizer; 04-12-2012 at 04:36 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script automation using case statement

Hi, I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer. The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies

2. UNIX for Advanced & Expert Users

Running a script during logoff

I know we can put whatever we need to run during login inside /etc/profile or .profile file. I want to run a set of commands before logoff. Where should I put my commands/scripts? Is such facility available? (3 Replies)
Discussion started by: praveenkumar_l
3 Replies

3. Shell Programming and Scripting

what is problem with this small shell script.. case statement related

Hi All, this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem. #!/bin/bash echo "Enter the character" read a case $a in )... (2 Replies)
Discussion started by: johnray31
2 Replies

4. Shell Programming and Scripting

shell script case statement

In a case statement like below : case $rental in "car") echo "For $rental Rs.20 per k/m";; "van") echo "For $rental Rs.10 per k/m";; "jeep") echo "For $rental Rs.5 per k/m";; "bicycle") echo "For $rental 20 paisa per k/m";; *) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies

5. Shell Programming and Scripting

Logon/Logoff script

I need help for writing a logon/logoff script for recording user's computer usage time. This is for local login only, not for ssh or something like that. When a user logon, there should be a temp file (/home/acct/login_temp) generated including the logname and logon time information in the... (8 Replies)
Discussion started by: jimx
8 Replies

6. Shell Programming and Scripting

Help With Loop in Case Statement script

I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far: #!... (2 Replies)
Discussion started by: Emin_Em
2 Replies

7. Homework & Coursework Questions

Problem with executing a possible if or case statement script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a phonebook program. It should use functions to perform the required tasks. It should be menu-based,... (1 Reply)
Discussion started by: Rgasin02
1 Replies

8. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

9. Shell Programming and Scripting

Case statement in UNIX shell script

have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*). #!/bin/sh #Get a string from user and check whether its a existing filename or not rm str2 rm str3 echo "enter a file \c" read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies

10. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
ALTER 
USER(7) SQL Commands ALTER USER(7) NAME
ALTER USER - change a database user account SYNOPSIS
ALTER USER username [ [ WITH ] option [ ... ] ] where option can be: [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | CREATEDB | NOCREATEDB | CREATEUSER | NOCREATEUSER | VALID UNTIL 'abstime' ALTER USER username SET variable { TO | = } { value | DEFAULT } ALTER USER username RESET variable DESCRIPTION
ALTER USER is used to change the attributes of a PostgreSQL user account. Attributes not mentioned in the command retain their previous settings. The first variant of this command in the synopsis changes certain global user privileges and authentication settings. (See below for details.) Only a database superuser can change privileges and password expiration with this command. Ordinary users can only change their own password. The second and the third variant change a user's session default for a specified configuration variable. Whenever the user subsequently starts a new session, the specified value becomes the session default, overriding whatever setting is present in postgresql.conf or has been received from the postmaster. Ordinary users can change their own session defaults. Superusers can change anyone's session defaults. PARAMETERS username The name of the user whose attributes are to be altered. password The new password to be used for this account. ENCRYPTED UNENCRYPTED These key words control whether the password is stored encrypted in pg_shadow. (See CREATE USER [create_user(7)] for more informa- tion about this choice.) CREATEDB NOCREATEDB These clauses define a user's ability to create databases. If CREATEDB is specified, the user being defined will be allowed to cre- ate his own databases. Using NOCREATEDB will deny a user the ability to create databases. CREATEUSER NOCREATEUSER These clauses determine whether a user will be permitted to create new users himself. This option will also make the user a supe- ruser who can override all access restrictions. abstime The date (and, optionally, the time) at which this user's password is to expire. variable value Set this user's session default for the specified configuration variable to the given value. If value is DEFAULT or, equivalently, RESET is used, the user-specific variable setting is removed and the user will inherit the system-wide default setting in new ses- sions. Use RESET ALL to clear all settings. See SET [set(7)] and the Administrator's Guide for more information about allowed variable names and values. DIAGNOSTICS
ALTER USER Message returned if the alteration was successful. ERROR: ALTER USER: user "username" does not exist Error message returned if the specified user is not known to the database. NOTES
Use CREATE USER [create_user(7)] to add new users, and DROP USER [drop_user(7)] to remove a user. ALTER USER cannot change a user's group memberships. Use ALTER GROUP [alter_group(7)] to do that. Using ALTER DATABASE [alter_database(7)], it is also possible to tie a session default to a specific database rather than a user. EXAMPLES
Change a user password: ALTER USER davide WITH PASSWORD 'hu8jmn3'; Change a user's valid until date: ALTER USER manuel VALID UNTIL 'Jan 31 2030'; Change a user's valid until date, specifying that his authorization should expire at midday on 4th May 1998 using the time zone which is one hour ahead of UTC: ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1'; Give a user the ability to create other users and new databases: ALTER USER miriam CREATEUSER CREATEDB; COMPATIBILITY
The ALTER USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation. SEE ALSO
CREATE USER [create_user(7)], DROP USER [drop_user(l)], SET [set(l)] SQL - Language Statements 2002-11-22 ALTER USER(7)
All times are GMT -4. The time now is 09:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy