LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-22-2012, 04:12 AM   #1
peacepanda
LQ Newbie
 
Registered: Oct 2012
Posts: 26

Rep: Reputation: Disabled
Scripting in genral?


I need some guidelines to write a shell script that has following problem statement.Please suggest.

Need to write a shell script that will go to list of servers.
Go into the mentioned folders and check for a particular string and ask from the user if he wants to change a occurence with anoter string.

Thanks,
Ajit
 
Old 11-22-2012, 04:25 AM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
Guidelines?
  • Document well; you will be surprised how much you will have forgotten in only six months
  • Define the problem clearly
  • For the cases in which you can't define the problem clearly, define the things that you can't define
  • You'll want to test - try to define the test cases in advance of writing anything, and then when you have written something revisit that definition of test cases
  • Think about what options you'll want the script to have; the first thing is to get the 'main option' working, but think about what extra options could be helpful and how the user interface might work
  • Post your initial code on this website - you'll get helpful comments

Good luck!
 
2 members found this post helpful.
Old 11-22-2012, 10:09 AM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,077

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
Quote:
Originally Posted by peacepanda View Post
I need some guidelines to write a shell script that has following problem statement.Please suggest.
Need to write a shell script that will go to list of servers.
Go into the mentioned folders and check for a particular string and ask from the user if he wants to change a occurence with anoter string.
We'll be glad to help....so post what you've written/tried so far, and where you're stuck. However, we're not going to write scripts for you.

Have you looked at the bash scripting tutorials??
http://tldp.org/LDP/abs/html/

Running an interactive command on another server is going to be a challenge. A tool like puppet or fanout may already do what you're looking for.
 
Old 11-22-2012, 10:18 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
My first guideline is to clearly define and state what you really want. Your problem description leaves a lot of gaps. For instance: 'a shell script that will go to list of servers' Go to? What do you mean by 'go to' a server? Make a network connection? What kind of servers? File servers? Web servers? Database servers? Are they on the local host, or out there somewhere on a network?
Another vagary: 'list of servers'. Where is the list? In a file? To be provided from a user? In a shell variable? It is necessary to know this in order for the script to read and parse the list.

You need to recognize that no one reading your description here knows anything whatsoever about the problem. Nothing. Everything has to be spelled out unambiguously. The benefit of doing that will be that it allows you to really think about the elements of the problem in terms that will be part of the solution. So, when someone provides a suggestion, or asks for more information, you will already be thinking in similar terms. It is a bit like the concept that the best way to learn some subject is to teach it. Teach us the details of the problem, and by doing so, start learning about the solution.

--- rod.

Last edited by theNbomr; 11-22-2012 at 10:20 PM.
 
2 members found this post helpful.
Old 11-23-2012, 04:25 AM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
Thanks to the theNbomr for that; that is exactly the kind of thing that I had in mind.

You'll be surprised at the extent to which having to state the requirements makes you go through an '...I thought the problem was defined, but now I realise that I have no idea about this aspect..' cycle.

One important aspect that hasn't been mentioned so far is the response of the server: what is intended to happen if a server is down, the network connection is not working or the server only responds slowly? You have to think through the bad stuff that can happen and ensure that you do something sensible (and what qualifies as 'sensible' is heavily dependant on the context stuff that you've spent little time telling us).
 
1 members found this post helpful.
  


Reply

Tags
shell script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 05:02 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
genral netwoking Damon Spector General 3 03-24-2005 02:54 AM
Genral Questions on Types of Linux Files roiboy Linux - Newbie 4 04-27-2004 09:22 PM
genral karthiksrinivas Linux - General 5 09-13-2003 12:31 PM


All times are GMT -5. The time now is 05:31 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration