LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash Script Help/Fedora 15 (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-help-fedora-15-a-941763/)

DaverR 04-25-2012 10:41 PM

Bash Script Help/Fedora 15
 
Hello Everyone.

I am trying to create a bash script to do two things based on user input. The first one is to configure a static ip address on the computer and save it to the desktop.

The second is to set up a secure remote connection I am assuming with ssh. Both of the scripts are based on asking for input from the user. I want to keep it as simple as possible. I have been using the case along with read for the rest of the script. The beginning of the script gives the user options to choose from to execute each command. Both configurations will be similiar in the examples. The user would select ssh for the remote connection option. Thanks for all your help.

Example: echo "Please select s to change the ip address to static"
case "$answer" in

s)

echo "You have selected s"

ifconfig -a

echo "Please enter the name of the device and the ip address"

read answer

command here "$answer" (after changing it needs to be saved as a file on the desktop)

jv2112 04-26-2012 03:31 AM

Sounds like homework................... :-(

David the H. 04-26-2012 03:55 AM

What I don't see here is any actual question/problem. What do you want from us?

As mentioned, if this is homework we won't do it for you, but we can help guide you towards a solution.

And please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.

DaverR 04-26-2012 06:33 AM

David

I am sorry if I was not clear. Yes this is homework. I am trying to find the right commands to make these work. The first one I can figure out how to set a static ip address. The part I am having trouble with is trying to figure out how to use the command line to save it to the desktop when I am finished. The second part with ssh I am trying to figure out is the right commands to get it started. I don't expect anyone to do it for me. If there is documentation on both procedures somewhere else that is not confusing to a first time script writer I would appreciate it to get pointed in the right direction. I have done all kinds of reading on this and most of it is very technical. I need it broken down in simple terms. I am not new to computers but I don't have much experience with Linux on the command line. I don't have any experience in script writing. I am 44 and this is a career change for me. I am just very limited on time and need to find the solution with out endless searching. I appreciate any suggestions or guidance anyone could give me. I ask everyone's forgiveness if I seem a little clumsy at this. I will do my best to follow the procedures in the postings. Thanks for all your help.

grail 04-26-2012 06:55 AM

Not sure I understand the "save to the desktop" part? You want to put the output of ifconfig in a file on the desktop?

As for ssh, both the man page and google have heaps of insight into how to use it.

Generally we like to help when you are stuck after trying something and need a slight tweak. Also, as it is homework, most answers will probably be of the form, see link or man page.

So if you could answer my first question and then go with suck it and see with ssh on the command line, then it is trivial to place into a script (usually :) )

DaverR 04-26-2012 11:10 AM

Grail

On the first question yes I am trying to save the output as a file on the desktop. I will look more into ssh as you suggested. I know it can't be that hard. With my work and school it gets frustrating not being able to spend as much time as I would like learning this stuff. It is just unbelievable how much information is out there. Thanks for your help Grail.

grail 04-26-2012 11:52 AM

See if this helps for the first one: http://mywiki.wooledge.org/BashGuide/InputAndOutput

DaverR 04-26-2012 10:38 PM

Grail

Thanks for the push in the right direction. It did help me get what I needed. I was able to complete my script and get everything working. My hat is off to all of you Linux gurus. I have been toying with Linux for about a couple of years now but it wasn't until I took this class that it opened my eyes to what is really out there. I know my use of code will always be limited due to my entrance so late in the game. All of you that can write programs are the real masters. I hope to someday make Linux my primary operating system of choice. I really appreciate everyone's help. Thanks for all your patience and understanding! Good day everyone!

grail 04-26-2012 11:53 PM

Quote:

I know my use of code will always be limited due to my entrance so late in the game.
Don't let age hold you back ... I am in my 40's too and it is a case of doing little bits here and there that eventually get you going :)

DaverR 04-27-2012 10:53 PM

Thanks for the support grail. Its nice to know I am not the only one out here. I have learned so much over the last couple of years and I am thirsty for more. I can't wait until I am done with school so I can sit back and soak it all in. When I am done with school I hope to get into networking or pc support and administration. We will have to see. I work in the shipping department where I am at. By next summer I should be working in the field. I am taking my A+ Cert. on Monday and retaking my Network+ over the summer along with Windows 7. (ugh. Have a great night.

grail 04-27-2012 11:45 PM

Good luck :)


All times are GMT -5. The time now is 02:21 PM.