Sponsored Content
Top Forums Shell Programming and Scripting help with ksh parsing traceroute output Post 302374080 by smurphy_it on Monday 23rd of November 2009 10:48:57 AM
Old 11-23-2009
Power help with ksh parsing traceroute output

Good day. I am doing an enq -WA (AIX), to get a list of the print queues, I then compare that to the /etc/hosts file to 'match' the IP address associated with the print queues. What I want to do is to run a traceroute with up to 5 hops, and perform an output to a file with some "specific items". Here is what I have so far...

Code:
#!/bin/ksh
# -- Variables --
HOSTS=/etc/hosts
CFG=/tmp/pqueue.cfg.$$
TROUTE=/tmp/troute.log.$$

for i in `/usr/bin/enq -WA | grep -v ^Queue | grep -v -- ^----- | cut -f 1 -d \ ` ; do grep $i $HOSTS ; done | grep -v ^\# | awk {'print "define host{\n \tuse\t\tgeneric-printer\n\thost_name\t"$2"\n\taddress \t"$1"\n\thostgroups\tdi-printers\n"'} > CFG

for j in `cat $CFG | grep address | cut -f 2 -d \ ` ; do echo "\n" "$j" && traceroute -q2 -m5 $j | awk '{print $3}' | grep "(" | tr -d "(" | tr -d ")" | tr "\n" "," ; done | sed s/\,//2 > $TROUTE


Does anyone have a better way of doing this. What I want to do is get a list of all of the Print Queues and their IP addresses, as well as the Parents (from the Traceroute hops) and output it all into a text file which would be acceptable for nagios.

Any help would be appreciated, and yes as you have probably gathered I am quite a Newb when it comes to shell scripting.

Last edited by Franklin52; 11-24-2009 at 04:32 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

traceroute output?

I understand the concept of traceroute - can anyone explain the output to me e.g. 39ms 39ms 39ms are these the times for each trip it takes? Assuming each machine is pinged 3 times. and how does the RTT work? Is this the time it takes from one machine to another because it doesn't look like... (6 Replies)
Discussion started by: justine petrie
6 Replies

2. Shell Programming and Scripting

Parsing and getting data from XML file using ksh script

Hi All, I have a xml file for example as described below <xml> <address> <street><street> <address/> <isbn>426728783932020308393930303</isbn> <book> <name> </name> </book> . . . </xml> My problem is to get the isbn number from the above described file using ksh script. Could... (6 Replies)
Discussion started by: vinna
6 Replies

3. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

4. IP Networking

Puzzling Traceroute output

This is the output that I get every so often when trying to do a traceroute to the web server whenever it's inaccessible: traceroute to 64.40.98.181 (64.40.98.181), 30 hops max, 40 byte packets 1 207.97.207.194 (207.97.207.194) 2.625 ms 2.840 ms 2.968 ms 2 core1-5.iad1.rackspace.com... (6 Replies)
Discussion started by: gaspol
6 Replies

5. Shell Programming and Scripting

Need help parsing config file in ksh

Hi all, I've done some searching here but haven't found exactly what I'm looking for so I thought I'd post up and see if someone can help out. I'm working on a shell script that I would like to store environment variables in an external file. I'm familiar with sourcing a file with variables in... (1 Reply)
Discussion started by: kungfusnwbrdr
1 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. Shell Programming and Scripting

Traceroute script weird output

This script is giving weird output #!/bin/bash NETPATH=(`/bin/traceroute -n 4.2.2.2 | awk '{print $2}'`) for i in "${NETPATH}" do echo $i done The output: to 11.11.11.1 1.1.1.1 99.111.208.2 traceroute_test.sh traceroute_test.sh (7 Replies)
Discussion started by: thumbs
7 Replies

8. Shell Programming and Scripting

XML parsing in KSH

Hi All, Although I was able to find past XML parsing questions, as the questions were a little different than this, I had a pretty hard time adapting those answers to this scenario. -> May I ask if anyone knows how to extract the IP addresses of the below "servers.xml" file into an array... (5 Replies)
Discussion started by: chatguy
5 Replies

9. Shell Programming and Scripting

Parsing ksh script

Is there any tool that can parsing ksh script into grammar format? e.g. the tool can parse the following ksh script: echo "hello"> abc.txt cp /home/user/abc/.profile /home/user/abc/myprofile into GENERATE abc.txt COPY /home/user/abc/.profile TO /home/user/abc/myprofile My server OS... (2 Replies)
Discussion started by: cstsang
2 Replies

10. Shell Programming and Scripting

ksh parsing arguments in a string rather than from the cmdln

Hi. I have a piece of code that reads and parses command line options. I'd like to alter it slightly to read from a string (that's set elsewhere in the script) rather than directly from the command line (arg). Can somebody show me how to do this? Many thanks. My code is as follows: typeset... (6 Replies)
Discussion started by: user052009
6 Replies
lpmove(1M)						  System Administration Commands						lpmove(1M)

NAME
lpmove - move print requests SYNOPSIS
lpmove [request-ID] destination lpmove source destination DESCRIPTION
The lpmove command moves print requests queued by lp(1) or lpr(1B) between destinations. The first form of lpmove moves specific print requests (request-ID) to a specific destination. The second form of the lpmove command moves all print requests from one destination (destination1) to another (destination2). This form of lpmove also rejects new print requests for destination1. lpmove moves individual requests or entire queues only within an instance of a print service, not between a local and a remote queues or local queues on different instances of a print service. Requests can only be moved if the print service or protocol supports it. The LP print server and IPP print protocol both support moving requests between queues. The BSD print protocol does not. When moving requests, lpmove does not check the acceptance status of the destination to which the print requests are being moved (see accept(1M)). lpmove does not move requests that have options (for example, content type or requiring a special form) that cannot be handled by the new destination. OPERANDS
The following operands are supported: request-ID The specific print request to be moved. Specify request-ID as the identifier associated with a print request as reported by lpstat. See lpstat(1). destination The name of the printer or class of printers (see lpadmin(1M)) to which lpmove moves a specified print request. Specify des- tination using atomic, URI-style (scheme://endpoint), POSIX-style (server:destination) syntax. source The name of the destination from which lpmove moves all print requests. Specify destination using atomic, URI-style (scheme://endpoint), POSIX-style (server:destination) syntax. See printers.conf(4) for information regarding the naming conventions for atomic names and standards(5) for information regarding POSIX. EXIT STATUS
The following exit values are returned: 0 Successful completion. non-zero An error occurred. FILES
/etc/printers.conf System printer configuration database $HOME/.printers User-configurable printer database ou=printers LDAP version of /etc/printers.conf printers.conf.byname NIS version of /etc/printers.conf printers.org_dir NIS+ version of /etc/printers.conf ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWlp-cmds | +-----------------------------+-----------------------------+ |Interface Stability |Obsolete | +-----------------------------+-----------------------------+ SEE ALSO
lp(1), lpr(1B), lpstat(1), accept(1M), lpadmin(1M), lpsched(1M), printers.conf(4), attributes(5), standards(5) System Administration Guide: Solaris Printing NOTES
When IPP is in use, the user is prompted for a passphsrase if the remote print service is configured to require authentication. SunOS 5.11 6 Jun 2006 lpmove(1M)
All times are GMT -4. The time now is 08:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy