Linux - NewbieThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is due in about 6hours and i need to make it perfect. Please help me on this again guys.
My teacher has a program that will be run to test my program. Therefor i can't use read to make the user input the arguments.
Can you please help me and also see what else i can do to make this better. Thanks Guys.
Ohh and we are limited to using the following:
1) test
2) printf
3) echo
4) sleep
5) expr
6) exit
7) basename
8) readonly
9) grep
im so screwed arnt i?
---------- Post added 04-29-11 at 06:46 PM ----------
Code:
####################################################################
# #
# Program: a1 #
# #
# Date: 08/04/11 #
# Programmer: Justin Kaese #
# #
# This program will take command line arguments -s NN where NN #
# is the delay in whole seconds and in the range of 1 <= NN <= 60. #
# #
# It will then display the date in the format dd-mm-yyyy #
# ten times NN seconds apart. #
# #
####################################################################
################################################
# Assume that the user will enter 'a1' for inp1
################################################
read inp1 inp2 inp3
############################################
# see if there are enough command arguments
############################################
if [ "$inp2" == "" ];
then
echo "ERROR:not enough command line arguments
Usage: a1 -s NN, where NN is in the range 1 - 60 inclusive
exit code from program is 1"
else
if [ "$inp3" == "" ];
then
echo "ERROR:not enough command line arguments
Usage: a1 -s NN, where NN is in the range 1 - 60 inclusive
exit code from program is 1"
else
########################
# Make sure inp2 = "-s"
########################
if [ "$inp2" == "-s" ];
then
#################################
# make sure inp 3 is an interger
#################################
if [[ $inp3 =~ ^[0-9]+$ ]];
then
###########################################
# make sure inp3 is in the rage of 1 to 60
###########################################
if [ $inp3 -gt 0 ] && [ $inp3 -le 60 ];
then
############################
# Create a loop for input 2
############################
for i in {1..10};
################################
# Print the date in this format
################################
do printf "%2s) " $i & date +%d-%m-%Y": "%H-%M-%S;
####################
# Sleep for input 3
####################
sleep $inp3
done
echo " "
echo "exit code from program is 0"
else
echo "ERROR:number of seconds is outside reqired range
Usage: a1 -s NN, where NN is the range 1 - 60 inclusive
exit code from program is 5"
fi
else echo "ERROR:seconds not an integer
Usage: a1 -s NN, where NN is in the range 1 - 60 inclusive
exit code from program is 4"
fi
else echo "ERROR: did not supply the -s option
Usage: a1 -s NN, where NN is in the range 1 - 60 inclusive
exit code from program is 5"
fi
fi
exit;
fi
Last edited by CygwinU; 04-30-2011 at 07:58 PM.
Reason: Put my code in code tags
Welcome to LQ. Hope your time here helps you as much as mine has helped me.
Amplifying arizonagroovejet's (righteous) request:
Please put code, command line output, config files, etc. inside [CODE] tags, aka "Code:" blocks.
It will make your posts easier to read, & that will get you more, faster, better answers. -- Help us help you.
BTW, You can edit your post(s) to do this retroactively.
Also, please read or re-read the LQ Rules, paying especial note to:
Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
We, well many of us, will guide you to answers to specific problems; especially is you are up front about the fact that it is homework.
My teacher has a program that will be run to test my program. Therefor i can't use read to make the user input the arguments.
You could if the teacher's program fed the input to your script's stdin but you can't because read is not on the list of allowed commands (neither is [ which is a shell builtin, same as most of the rest of the list) so you can't.
I'm looking for a programming tutor as im so far behind in my Diploma. Can anyone push me in the right direction?
My teacher is incredibly smart as a programmer but he sucks as a teacher.
I need help with my bash and also Java and C++.
I cant find anything legit on programming tutors though i'm willing to pay anyone that has the time and can help me.
Thanks again guys!
If you're looking for a tutor it might help if you provided your location, though the chances of anyone here being close enough to help seem slim. You could look for a local Linux Users Group. You could also try telling your teacher that you are having trouble, they might have contacts who could provide additional tutoring or be able to provide it themselves. If your teacher really does suck as a teacher, (as opposed to it being just you who thinks they do), then you won't be the only one having trouble with courses they teach and you and the other students could get together and raise this with the relevant authority.
I'm looking for a programming tutor as im so far behind in my Diploma. Can anyone push me in the right direction?
My teacher is incredibly smart as a programmer but he sucks as a teacher.
I need help with my bash and also Java and C++.
I cant find anything legit on programming tutors though i'm willing to pay anyone that has the time and can help me.
Thanks again guys!
p.s. so glad i found this forum.
Depending on your level, tutors advertise at Student Centers, Student Affairs or even your instructor may have a select list. You could approach someone in your class that could possibly help.
If your teacher really does suck as a teacher, (as opposed to it being just you who thinks they do)
Thank you for your help. I sent a partition around the class and i would say 90% signed it agreeing that we need more help or a new teacher.
ofcourse the admin were very protective of their teacher and they brushed it off. Since then, myself and a couple of the other students have resorted to youtube tutorials to get the teacher we need. In saying that, we have passed all that basic tutorials can really teach us and need more.
Thank you for your help once again and i guess its just up to me to figure it all out from here. .
"I sent a partition around the class..." & not the entire hard drive, quite a feat!
Seriously, I assume you meant "petition". -- You can edit your post to correct the spelling, if you like.
BTW, good luck w/ getting a better teacher. I have 2ce, that I can still remember after 40 years, been stuck in a similar situation; neither ended well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.