473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Shell Script to List Node Definitions

Colloid Snake
144 100+
Hello everyone-

I am working on a shell script to parse out a Node.def file that contains the hostname, version, IP address, and date updated. There is a separate .def file for each node (of which there are several hundred), and each node is in a separate directory.

I am attempting to extract the node name and IP address from each .def file and compile these into a single file, but I'm getting an error, no matter what I alter, so I think I'm just not setting this up properly. Can anyone help?

Expand|Select|Wrap|Line Numbers
  1. echo "`date` - List of names and correlating IPs for `hostname`" > SensorList.txt
  2.  
  3. set file_list = `find . -name "*.def" -type f`
  4.  
  5. for $file in file_list 
  6.    # extract name and ip from file
  7. do
  8.    `cat $file | grep "NAME=*"` >> SensorList.txt
  9.    `cat $file | grep "IP=*"` >> SensorList.txt
  10. done
  11.  
Error:
# ./CreateSensorList.sh
./CreateSensorList.sh: file_list: command not found
cat: file_list: No such file or directory
cat: file_list: No such file or directory

I have attempted to move around the `` to encompass different things, add/remove the $ in the for, etc... And I'm currently out of ideas, so any help would be appreciated.
May 6 '08 #1
2 2602
ashitpro
542 Expert 512MB
Hello everyone-

I am working on a shell script to parse out a Node.def file that contains the hostname, version, IP address, and date updated. There is a separate .def file for each node (of which there are several hundred), and each node is in a separate directory.

I am attempting to extract the node name and IP address from each .def file and compile these into a single file, but I'm getting an error, no matter what I alter, so I think I'm just not setting this up properly. Can anyone help?

Expand|Select|Wrap|Line Numbers
  1. echo "`date` - List of names and correlating IPs for `hostname`" > SensorList.txt
  2.  
  3. set file_list = `find . -name "*.def" -type f`
  4.  
  5. for $file in file_list 
  6.    # extract name and ip from file
  7. do
  8.    `cat $file | grep "NAME=*"` >> SensorList.txt
  9.    `cat $file | grep "IP=*"` >> SensorList.txt
  10. done
  11.  
Error:
# ./CreateSensorList.sh
./CreateSensorList.sh: file_list: command not found
cat: file_list: No such file or directory
cat: file_list: No such file or directory

I have attempted to move around the `` to encompass different things, add/remove the $ in the for, etc... And I'm currently out of ideas, so any help would be appreciated.



please have a look at following script..it should work

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "`date` - List of names and correlating IPs for `hostname`" > SensorList.txt
  3. file_list=`find . -name "*.def" -type f`
  4. for file in $file_list
  5. # extract name and ip from file
  6. do
  7.   echo $file
  8.   `cat $file | grep "NAME=*"` >> SensorList.txt
  9.   `cat $file | grep "IP=*"` >> SensorList.txt
  10. done
  11.  
  12.  
check out the second line.
you don't have to use 'set' to initialize the local variable..it is used to set the environmental variables.
Don't put spaces before and after '=' operator.
In third line use '$file_list' instead 'file_list'

Rest is fine.....
May 7 '08 #2
Colloid Snake
144 100+
Ah, thank you very much! I also removed both of the `` around the cat $file... lines to get it to run (and the ='s are in search strings, that's how the file is set up so I left those in) and it's working now.

Thanks again

~Snake
May 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Alvaro G Vicario | last post by:
I have a list built on HTML and CSS: <ul> <li>Foo</li> <li>Bar <ul> <li>Gee</li> </ul> </li> </ul>
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
1
by: Tim | last post by:
I can't seem to figure out why this very simple linked list wont build.. I mean, there is no intelligence, just add to end. Anyway, please let me know if something i can do will make head (the...
1
by: TPK | last post by:
Here is what I want to do with javascript. On a page with text place a javascript link that: 1) When a user clicks the link (onClick) a new browser window opens (the easy part) NewWindow =...
1
by: ahoway | last post by:
I am having problems deleting a node from a link list. I need to delete the node which contains the number six. This is what I have so far..... Thank you in advance. #include <iostream>...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
46
by: junky_fellow | last post by:
Hi, Is there any efficient way of finding the intesection point of two singly linked lists ? I mean to say that, there are two singly linked lists and they meet at some point. I want to find...
6
by: Hamster | last post by:
Hi, Need help with my code on reversing a singly linked list, here's my code: void reverseList ( List& listObj) { ListNode*pHeadnew=listObj.lastPtr, *pTailnew=listObj.firstPtr;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.