LinuxQuestions.org
Review your favorite Linux distribution.
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 07-18-2007, 10:14 AM   #1
kr0m3
LQ Newbie
 
Registered: Feb 2006
Location: 010101010101001101000001
Distribution: slackware
Posts: 7

Rep: Reputation: 0
Question shell script to read input from csv ip addresses?


greets...

I'm trying to figure a way to automate the input of about 130 different IP addresses for the following command:

Code:
fstool  sw traps -h <ip address> -c <community string> -s 1 -v 2
which is basically telling the device to listen to the switches (via ip address) for certain info...

im sure i can get the ip's into comma delimited fairly quickly, i'm just stuck on the bash script.
thoughts?

thnx in advance,
~k
 
Old 07-18-2007, 12:14 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Don't delimit the list with commas. Delimit it with spaces, and use the for ... in construct. For info on that construct:

Code:
man bash
or google:
Code:
bash "for loop"
Hope this helps.
 
Old 07-18-2007, 12:19 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,991
Blog Entries: 54

Rep: Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743
You *can* delimit by comma's, if you get your IP's in one var, then maybe
Code:
IPS=$@; IPS=${IPS//, / }; for IP in $IPS; do fstool sw traps -h $IP -c <community string> -s 1 -v 2 &; done
? (Or use a different IFS)
 
Old 07-21-2007, 08:51 AM   #4
kr0m3
LQ Newbie
 
Registered: Feb 2006
Location: 010101010101001101000001
Distribution: slackware
Posts: 7

Original Poster
Rep: Reputation: 0
thnx!

thanks for the assist, mi compadres. I'll give the for loop a shot first, i suppose.

how fun... yet another learning curve to add to the list!

~k
 
  


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
Help Please - averging input in a shell script reddawn Linux - Newbie 2 07-16-2006 01:44 PM
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 03:14 AM
Shell script to read from csv file hendemeg Programming 1 05-11-2004 08:23 PM
Shell script to change IP addresses saintt Linux - General 4 08-20-2001 11:17 AM


All times are GMT -5. The time now is 06:21 AM.

Main Menu
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