473,785 Members | 2,411 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:
# ./CreateSensorLis t.sh
./CreateSensorLis t.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 2619
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:
# ./CreateSensorLis t.sh
./CreateSensorLis t.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
4931
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 filename.py
4
2513
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
5779
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 macros */ #ifndef PUBLIC #define PUBLIC
1
2048
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 root pointer) not be null. /* LINKED LIST DEFINITIONS */ typedef struct a_fnode {
1
1643
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 = window.open("windowpage.html","newWin","width=100,height=100") 2) Once the window is open I want to pull a specific item from a list of items (array) and populate the open window with only that item. The
1
6570
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> #include "stdafx.h" using namespace std; class IntNode
13
12805
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 scripting language that makes writing automated tests simpler. Really, I'm looking to kind of abstract the power of the C# language into a simpler language that's easier to learn. The script files would be interpreted by a script interpreter...
46
3427
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 out the addres of the node where the two linked intersect. thanks for any help...
6
1594
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
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.