writing a shell
Hi
I have to write a shell for a computer science prac. I have no clue what to do. Please could someone help. I especially need help with implementing the command execution facility by parsing the command line. I also need help with implementing the path search capability. I need help by tomorrow. Please help!! |
that's not really going to happen is it? a few people have asked this before, have a search. you won't find much useful information though, seeing as it's a pretty vast thing to ask for.
|
I found the Bash code pretty helpful. I wish I could give you a link to it but I don't have it. If you want the tarball, I think I have that.
|
This is a derivative from a previous post I made. Shows command line
parsing (with "" support) and process forking (background procs not implemented). Code:
#include <stdio.h> completion. background procs would be nice. command line substitution (*, variables, etc) also. as for the parent post.... don't tell me you waited until the day before your project was due to rip off someone else's code? i hope i'm wrong. |
hi thanks for the code. NO I didn't wait till the last minute to do this. In the end I actually got it working, I worked with a group of friends. I handed it in on thurs
|
hopeless, do not ask about school questions here, we are NOT here to do your homework.
|
:confused: :newbie: :study:
Hi there I dont mean to annoy anyone but guidance here is much appreciated. I need to do a shell script for unix. This is what I have to do; An electric power distribution compnay charges the domestic consumers as follows; Consumption Units Rate of Charge 0-200 60 cents per unit 201-400 $120 plus 70 cents per unit excess of 200 401-600 $260 plus 80 cents per unit excess of 400 601 and above $420 plus $1.00 per unit excess of 600 Prepare a shell script which reads in customer number and power consumed and prints on the screen the amount to be paid by the customer(Call it powercal) Note: Unix can carry out mathematical functions on integers only. The shell variables store numbers as integers. The student has to devise a method to display the amount in terms of dollars and cents. All this after one lesson on scripting and I have no programming background, hence my dilemma. The other modules were fine. I just dont know where to begin and put them all together. Your help and guidance is greatly appreciated. Regards Keen_Eager |
well firstly this is homework, and it's not allowed, but i guess you do clearly ask for help, not a solution, so i'll let you also. secondly welcome to lq, but please start a new thread for new questions, don't tag along on old threads.
hmm, ok then with no idea of what your input is it's pretty trivial really. to do the actual work itself you would check the value used in a block test ( [ ] ) statement, i.e if it's less that 200, less than 400 etc.... and then inside each clause you would print your output Code:
if [ amountused -lt anothervalue ] as for getting those values, read the section about "read" way down in the bash manpage (quite near the end). naturally there are nicer and better ways to do everything, but that's really for you to learn in your own time. |
Quote:
I don't know who told you that but they never apparently heard of $(()). Hence... no2nt@grep# echo $((50.0*1.25)) 62.5 no2nt@grep# export a=65.1; export b=29.1; echo $(($a + $b)) 94..1999999999999989 something possibly helpful for formatting floats/doubles: no2nt@grep# echo `printf "%.2f" $((234.234 * 9092.23))` 2129709.40 welcome to lq! |
Thank You for help, it's appreciated from a newbie like me for the only programming i have done is on a vcr. Thanks again
regards keen_eager |
All times are GMT -5. The time now is 11:25 PM. |