LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 04-25-2012, 10:41 PM   #1
DaverR
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Rep: Reputation: Disabled
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)
 
Old 04-26-2012, 03:31 AM   #2
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 106Reputation: 106
Sounds like homework................... :-(
 
Old 04-26-2012, 03:55 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 04-26-2012, 06:33 AM   #4
DaverR
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-26-2012, 06:55 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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 )
 
Old 04-26-2012, 11:10 AM   #6
DaverR
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-26-2012, 11:52 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
See if this helps for the first one: http://mywiki.wooledge.org/BashGuide/InputAndOutput
 
Old 04-26-2012, 10:38 PM   #8
DaverR
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
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!
 
Old 04-26-2012, 11:53 PM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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
 
Old 04-27-2012, 10:53 PM   #10
DaverR
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-27-2012, 11:45 PM   #11
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Good luck
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get some bash scripts into a simple bash script with some echo and if statement. y0_gesh Programming 3 03-01-2012 09:46 AM
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 08:37 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
After a piece of software/a bash script to mass-move files [Fedora Core 6] Alux Linux - Desktop 3 11-23-2006 02:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration