Results 1 to 5 of 5
So, i'm sure that help with homework gets asked a lot here, but I'm not asking anyone to do it for me, I'm just stuck and my instructor is out ...
- 09-17-2011 #1Just Joined!
- Join Date
- Mar 2011
- Location
- West Jefferson, NC
- Posts
- 3
Beginner needs some help
So, i'm sure that help with homework gets asked a lot here, but I'm not asking anyone to do it for me, I'm just stuck and my instructor is out of town for the weekend and I cannot correspond with him.
Here is the assignment:
Create a script to create the script header documentation.
The script should allow the name of the new script to be passed. The script should update the scripts name and date in the documentation.
The script should also change the permissions on the script and open it in vi for editing.
So far this is what I have:
echo -e "#!bin/bash
echo -e "############################################# ###"
echo -e "What would you like to name your script? \c"
read $name
# I need to read in the date here
echo -e "Who is the Author of this script? \c"
read $author
echo -e "What is the purpose of this script? \c"
read $purpose
echo -e "Please input version information: \c"
read $version
echo -e "################################################# "
echo `cat > $name`
echo `chmod 700 $name`
Here's my problem. I know that my echo commands only output the text to the screen but I need it to output to a file named whatever you enter in under "Script Name" and I'm not quite sure on how to do it. I tried using the $name to make it name the file whatever you input but it keeps telling me "Ambiguous Command" Also, I need it to read in the date automatically in between Script name and Author where I have it commented.Again, I'm not asking you to do it for me, just give me a hand.
Furthermore, I might also mention that this is a very BASIC scripting tutorial that I am working on. We have only covered chmod, read, dot, test, and escape characters in about 1 hour of class time on Thursday morning.
- 09-19-2011 #2
You're right that we get a fair few homework questions, and they're not allowed here. The reason is (just as you state) that people don't want help, they come here hoping to get their homework done for them. I have no problem with asking for helping in the way you have, you've arrived here and said "here's my homework question", "here's my answer, but there's something wrong can you provide any pointers".
I'll only provide generic help, though. My advice is to learn to use the manual - do 'man' and the command you want to know about. Try it with the echo command (i.e. 'man echo') and it'll tell you all you need. You certainly can divert output from it to a file or to a particular stream, you just need to get the right incantation.
If you want to manipulate the date, take a look at the man page for the 'date' command - you can have it provide the date and/or time in whatever format you desire.Linux user #126863 - see http://linuxcounter.net/
- 09-19-2011 #3Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
I would also suggest that you take a look at the many scripts available to you in /etc/init.d/. They are a great source of examples of bash scripting (a good one to start with is /etc/init.d/functions).
- 09-19-2011 #4Just Joined!
- Join Date
- Mar 2011
- Location
- West Jefferson, NC
- Posts
- 3
Thanks for the reply's everyone. I was forgetting to append everything to $1 since that will be the 1st argument as it is entered after the initial script in the terminal. Works like a boss now.
- 09-20-2011 #5Linux user #126863 - see http://linuxcounter.net/


Reply With Quote
