Input date on script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Input date on script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-05-2012
lhareigh890 lhareigh890 is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 29 April 2013, 3:46 AM EDT
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Input date on script

How can I allow users to change the date and time in a script? Say the user1 wil login and he will be inputting the desired date (example format below). I will need this script so the user can login and change the date anytime during the day. I will not allow him to use any command except the date change so Im planning to incorporate a menu script on it. Pls help. Thanks

echo" pls input date"
date 12052012 -------user will type like this one for date
date -s 08:00:00------ user will type like this one for time

thanks,
lhareigh
Sponsored Links
    #2  
Old 12-05-2012
balajesuri's Avatar
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 21 July 2014, 11:56 PM EDT
Location: India
Posts: 1,816
Thanks: 24
Thanked 519 Times in 498 Posts
An example using case in bash:

Code:
#! /bin/bash

echo "Enter option: "
read option

case $option in
    1) echo "One" ;;
    2) echo "Two" ;;
    *) echo "Everything else"
esac

Sponsored Links
    #3  
Old 12-07-2012
lhareigh890 lhareigh890 is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 29 April 2013, 3:46 AM EDT
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
If a user input date 12072012, the system date will change to 12/07/2012. If a user will input date -s 23:00:00 the time will be change to 23:00:00.

Do you have any script on how can this be possible?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to delete files with an input for directories and an input for path/file *ShadowCat* Shell Programming and Scripting 3 06-28-2012 09:16 PM
The scope of the shell/perl script is to read the input text file. Validate the expiry date of each casmo Shell Programming and Scripting 5 04-21-2011 11:06 AM
Echo date variable from data input to a script iga3725 Shell Programming and Scripting 6 12-07-2010 12:00 PM
Get date range between 2 date input tanit Shell Programming and Scripting 3 04-21-2009 11:20 AM
Script to find files on a given input date ar.karan Shell Programming and Scripting 1 08-13-2007 10:07 PM



All times are GMT -4. The time now is 12:35 AM.