LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-14-2015, 12:36 AM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,462
Blog Entries: 6

Rep: Reputation: 51
Need help on shell script..


I have serveral nodes related files under /var/lib/ directory as shown below:

Code:
machine001.cluster.org 
machine002.cluster.org
machine003.cluster.org
machine004.cluster.org
I am trying to write a shell script which first finds out how many number of files are present in this directory. Then it should fetch the first name like machine001, machine002, machine003 etc. Then it should fetches ipaddress, hostname and netmask under machine001 first, then store it in some variable. Repeat this for all the nodes. How will the script look like?
 
Old 01-14-2015, 12:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
Quote:
Originally Posted by your_shadow03 View Post
How will the script look like?
Since you are trying to write a shell script you should show us. Post whatever you got.
 
Old 01-14-2015, 08:17 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,496

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Currently it 'looks like' you haven't written anything and want someone else to do it for you.
 
Old 01-14-2015, 11:18 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,801

Rep: Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176
Quote:
Originally Posted by your_shadow03 View Post
I have serveral nodes related files under /var/lib/ directory as shown below:

I am trying to write a shell script which first finds out how many number of files are present in this directory. Then it should fetch the first name like machine001, machine002, machine003 etc. Then it should fetches ipaddress, hostname and netmask under machine001 first, then store it in some variable. Repeat this for all the nodes. How will the script look like?
Great, so feel free to write your script, and let us know where you're stuck. Post what you wrote, and tell us what problems you're having.

Because this question seems VERY familiar:
http://www.linuxquestions.org/questi...pt-4175521292/
http://www.linuxquestions.org/questi...ng-4175520171/
http://www.linuxquestions.org/questi...pt-4175495822/
http://www.linuxquestions.org/questi...pt-4175495518/
http://www.linuxquestions.org/questi...lename-763089/
http://www.linuxquestions.org/questi...rmance-772369/
http://www.linuxquestions.org/questi...cation-771392/
http://www.linuxquestions.org/questi...-setup-785835/

After SEVEN YEARS, are you still unable to write a script, or apply what you've been told many times before?
 
1 members found this post helpful.
Old 01-15-2015, 08:08 AM   #5
igadoter
Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: slackware 12.2, scientific linux 6.4, knoppix 7.2, salix 14.1
Posts: 910

Rep: Reputation: Disabled
@TB0ne in this I am on the side of OP. Learning scripting for the purpose to run few simple scripts seems to be overkill.
 
Old 01-15-2015, 09:22 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,801

Rep: Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176
Quote:
Originally Posted by igadoter View Post
@TB0ne in this I am on the side of OP. Learning scripting for the purpose to run few simple scripts seems to be overkill.
No, asking people to write scripts for you is rude and lazy, period. If you don't want to learn, that's everyone's prerogative....but asking others to do your work for you FOR FREE is plain lazy.

This is a place to come for HELP, not HANDOUTS. If you want someone to do your work for you, then HIRE SOMEONE. Otherwise, show effort of your own.
 
Old 01-15-2015, 09:41 AM   #7
igadoter
Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: slackware 12.2, scientific linux 6.4, knoppix 7.2, salix 14.1
Posts: 910

Rep: Reputation: Disabled
@TB0ne do you have friends? They all have to pay for you for doing something? And let remind you that exactly Linux is for free. I never payed a dollar to those hard working people creating Linux and all open software. In English vocabulary I found the word "favor". There still is a hope. Meanwhile, nowadays webmasters and sysadmins are rather poorly paid on there part-time jobs.
 
Old 01-15-2015, 09:48 AM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,185

Rep: Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586
The OP hasn't provided anything further, so it's hard to help him.

Perhaps we could keep from arguing needlessly and give the OP a chance to reply to our questions.
 
1 members found this post helpful.
Old 01-15-2015, 10:12 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,801

Rep: Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176
Quote:
Originally Posted by igadoter View Post
@TB0ne do you have friends? They all have to pay for you for doing something? And let remind you that exactly Linux is for free. I never payed a dollar to those hard working people creating Linux and all open software. In English vocabulary I found the word "favor". There still is a hope.
For friends, certainly. And Linux IS free...just like LEARNING is free. If you want to use it, that's great...no one asks you to contribute. If you want to have something CUSTOMIZED or written just for you, then either:
  • Learn to do it yourself, using the MANY tools and examples available to you.
  • Pay someone to do it for you.
The first is totally free...and when you show EFFORT, people will be more than happy to help you. To put it more simply, if someone asked you to help paint their house, and then sat there and told YOU to do it while they watched, would you??? Or would you tell them to do their own work, or show effort?
Quote:
Meanwhile, nowadays webmasters and sysadmins are rather poorly paid on there part-time jobs.
Speak for yourself, thanks. Webmasters and admins who know their jobs are ALWAYS in demand and paid pretty well.
 
Old 01-15-2015, 10:16 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,801

Rep: Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176
Quote:
Originally Posted by szboardstretcher View Post
The OP hasn't provided anything further, so it's hard to help him. Perhaps we could keep from arguing needlessly and give the OP a chance to reply to our questions.
Agreed, but I find it inconceivable that there is actually an argument FOR someone not learning or showing any effort. Especially in this day and age, when Google can point you to THOUSANDS of examples with complete explanations in less than a second. There's no excuse anymore, other than just being lazy, especially for a trivially simple script.

If it's very complex and the user is new to things, and they post something saying they're stuck...then absolutely, they need help, because if they're beginners trying something very advanced, that's why sites like this exist. But to show NO effort and ask for a handout is entirely different.
 
Old 01-15-2015, 10:52 AM   #11
igadoter
Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: slackware 12.2, scientific linux 6.4, knoppix 7.2, salix 14.1
Posts: 910

Rep: Reputation: Disabled
@TB0ne My point is that your are discouraging others from support OP, for me it is not ok. Not everyone share your point of view. Your list misses one entry: 1) learn , 2) pay or 3) ask for help.
 
Old 01-15-2015, 12:39 PM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,801

Rep: Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176Reputation: 4176
Quote:
Originally Posted by igadoter View Post
@TB0ne My point is that your are discouraging others from support OP, for me it is not ok. Not everyone share your point of view.
I am not discouraging ANYONE from doing whatever they want. If YOU want to write scripts for everyone who asks, go right ahead...your time is your own, enjoy. I do notice, though, that you haven't actually posted one.
Quote:
Your list misses one entry: 1) learn , 2) pay or 3) ask for help.
Nope...the "ask for HELP", is there. I specifically said "when you EFFORT, people will be more than happy to help you" To define things more simply, so you understand the difference:
  • HELP means that YOU do some of the work, and others do some of the work.
  • A HANDOUT means that you sit there, while OTHERS do everything.
That is what the OP is asking for, and HAS asked for for SEVEN YEARS at this point. If you can walk, ride a bike, drive a car, or do anything else similar, that is because someone HELPED you to LEARN, so you could do it for yourself.

By what you're saying, it should be perfectly fine for you to ask someone to carry you around...after all, some people may not WANT to learn to walk; since they only walk short distances, why should they bother to learn?
 
Old 01-20-2015, 07:31 AM   #13
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,462
Blog Entries: 6

Original Poster
Rep: Reputation: 51
Sorry guys.. I was on vacation. I got the script long back written but couldnt find time to response back to this thread.

Thanks for all your suggestion though
 
  


Reply


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
Shell script for run an shell script on server using ssh bloodstreetboy Linux - Server 5 01-12-2013 03:23 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM


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