Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-06-2008, 12:30 AM
|
#1
|
|
Member
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292
Rep:
|
Shell Script for Unix Date ???
I need one shell script to change unix machine date ..
That script will take date as command line argument
Login and password should be hard coded in the script
Pls Help
|
|
|
|
02-06-2008, 12:39 AM
|
#2
|
|
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,569
|
And this is homework for which University?
|
|
|
|
02-06-2008, 12:59 AM
|
#3
|
|
Member
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292
Original Poster
Rep:
|
I am sorry if this is an easy questions...Will be thankful if you help me..Let yu tell myattempt:
echo –n “login”
sty -echo
echo -n "Password: "
stty -echo
read passwords
#tty echo
#echo "" # force a carriage return to be output
correct="$(cat /etc/verify)"
if [$password = $correct] ; then
echo “Enter the Year”
read y
echo “Enter the month”
read m
echo “Enter the Day”
read d
echo “The Date modified is $m-$d-$y”
else
failed=$((failed + 1))
Does the Concept sounds Good?
|
|
|
|
02-06-2008, 03:28 AM
|
#4
|
|
Senior Member
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006
Rep:
|
Please use the code -tags.
|
|
|
|
02-06-2008, 04:01 AM
|
#5
|
|
Member
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292
Original Poster
Rep:
|
I dint get it....Hows it work?
|
|
|
|
02-06-2008, 07:52 AM
|
#6
|
|
Member
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274
Rep:
|
You don't need to do a "force carriage return", by the way. \n works well I find. Also, you're not actually changing the date. You're just outputting that you are.
What Zmyrgel meant is to enclose your code in [ code ][ /code ] tags, without the spaces between the brackets and the letters. For example, here is your code in code tags:
Code:
echo –n “login”
sty -echo
echo -n "Password: "
stty -echo
read passwords
#tty echo
#echo "" # force a carriage return to be output
correct="$(cat /etc/verify)"
if [$password = $correct] ; then
echo “Enter the Year”
read y
echo “Enter the month”
read m
echo “Enter the Day”
read d
echo “The Date modified is $m-$d-$y”
else
failed=$((failed + 1))
Also, if this is homework, it's against forum rules to ask for help for homework.
|
|
|
|
02-06-2008, 11:07 PM
|
#7
|
|
Member
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292
Original Poster
Rep:
|
Okies...I got a point that code should be enclose within the code.
But why yu people are really not ready to help me out with this?
Pls Help me with this shell script?
I tried but couldnt help myself?
|
|
|
|
02-07-2008, 12:22 AM
|
#8
|
|
Member
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274
Rep:
|
We aren't very willing because it sounds an awful lot like homework. Additionally, the first page under a Google of "change linux date" reveals the answer...which might be another reason someone's not too willing. A 'man date' command would probably give you the answer, in fact! It's rather obvious that you've tried to rely on your existing knowledge to fix the problem, then asked for help without looking first.
Sorry to sound harsh, but the rules say no homework help. And generally you should try to find the answer on your own before asking.
Additional places you could've looked:
LinuxQuestions Wiki
Forum search
After learning and understanding the information, it should be trivial to use variables to set the date.
Google - It's Your Friend
Last edited by LinuxCrayon; 02-07-2008 at 12:23 AM.
Reason: Link error
|
|
|
|
02-07-2008, 03:27 AM
|
#9
|
|
Member
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292
Original Poster
Rep:
|
Lemme take it as a challenge..Good Inspirational Task
|
|
|
|
02-07-2008, 03:44 AM
|
#10
|
|
Member
Registered: Oct 2005
Distribution: Ubuntu 9.04
Posts: 124
Rep:
|
are you a programmer, are you asking help because you need help with shell script?
i can see helping with the homeworks is against the rules, otherwise it would break the whole education system..but maybe i can give you start..
first of all look for a bash scripting tutorial and write a small hello world example. if you are a programmer you would understand the syntax quickly.
Then get a little bit deeper and learn how to manipulate variables, functions, I/O. After getting an abstract idea of the scripting language google for the functions you need. how to change the date, how to read user name etc..
final part is obvious..just combine them..write your code..if you then have problem, and you post your code, i think(not 100% sure  ) you will get help as it is no more your homework but a spesific question.
|
|
|
|
02-07-2008, 04:49 PM
|
#11
|
|
Member
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274
Rep:
|
Quote:
Originally Posted by laucian
are you a programmer, are you asking help because you need help with shell script?
i can see helping with the homeworks is against the rules, otherwise it would break the whole education system..but maybe i can give you start..
first of all look for a bash scripting tutorial and write a small hello world example. if you are a programmer you would understand the syntax quickly.
Then get a little bit deeper and learn how to manipulate variables, functions, I/O. After getting an abstract idea of the scripting language google for the functions you need. how to change the date, how to read user name etc..
final part is obvious..just combine them..write your code..if you then have problem, and you post your code, i think(not 100% sure  ) you will get help as it is no more your homework but a spesific question.
|
He's already shown that he has at least SOME understanding of scripting/BASH. In fact, he's only missing MAYBE two or three lines from his example.
|
|
|
|
02-08-2008, 12:58 AM
|
#12
|
|
Member
Registered: Oct 2005
Distribution: Ubuntu 9.04
Posts: 124
Rep:
|
you are right, i don't how but i've missed that..
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:44 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|