I need help writing 2 different Scripts the first is a Greeting Script based on the time of day. If the script is executed for example ./myscript 8 I should get a response of "Good Morning" if I execute ./myscript 14 I should get a response of "Good Afternoon'' and so on. I found some scripts online that automatically look up the current time and display the corresponding message by only entering ./myscript, but my Teacher wants us to have to enter the number representing the current time manually following the script command as stated above.
The second Script is a LeapYear script, you input a year and the script returns an answer whether it is a Leap year or not. Again I found a script online for this that ask you to enter the Year after the script is executed and again the Teacher wants the year entered manually following the script command like so:
./myleapYearscript 2016 These are the first scripts I have ever written/copied so I have no idea how to write it so they will take user input off the command line following the script execution, any help is always appreciated. Thank you
Here is the automatic Greeting Script that I am using that needs to be altered to accept manual input:
h=`date +%H`
if [ $h -lt 11 ]; then
echo Good morning
elif [ $h -lt 17 ]; then echo Good afternoon
else echo Good evening
fi
The second Script is a LeapYear script, you input a year and the script returns an answer whether it is a Leap year or not. Again I found a script online for this that ask you to enter the Year after the script is executed and again the Teacher wants the year entered manually following the script command like so:
./myleapYearscript 2016 These are the first scripts I have ever written/copied so I have no idea how to write it so they will take user input off the command line following the script execution, any help is always appreciated. Thank you
Here is the automatic Greeting Script that I am using that needs to be altered to accept manual input:
h=`date +%H`
if [ $h -lt 11 ]; then
echo Good morning
elif [ $h -lt 17 ]; then echo Good afternoon
else echo Good evening
fi