473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shell Script to List Node Definitions

Colloid Snake
144 New Member
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 2604
ashitpro
542 Recognized Expert Contributor
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 New Member
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
4911
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
2487
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
5715
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
2021
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
1624
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
6547
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
12768
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
3377
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
1570
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
7125
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
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
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...
1
6885
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
7379
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
5462
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,...
1
4908
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...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.