The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read the csv file and assign the values in to variable rajbal Shell Programming and Scripting 11 06-27-2009 02:17 PM
Read a file and assign the values to a variable depakjan Shell Programming and Scripting 5 06-10-2009 06:01 PM
Separating values from a file and putting to a variable ultimatix Shell Programming and Scripting 2 10-29-2008 03:43 PM
Reading file and assigning that to Variable Vaddadi Shell Programming and Scripting 2 04-03-2008 03:49 PM
How can I read variable values from file? redlotus72 UNIX for Dummies Questions & Answers 1 03-14-2005 05:38 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-26-2009
sagii sagii is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 22
Reading variable from file variable values

Hi,
Here is the output of lpstat. I would like to read value of Queue which is(abxxxxb1)and status that is DOWN in first line. i dont care what is in second line. any one can help me.thanks
Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- ------------------ ---------- ---- -- -----
abxxxxb1 abxxx DOWN
QUEUED 180 /xxx_home/yyy 1 1 1
  #2 (permalink)  
Old 06-26-2009
edgarvm edgarvm is offline
Registered User
  
 

Join Date: May 2009
Posts: 26

Code:
lpstat | awk '{if($1=="abxxxxb1") { print $2}}'
lpstat | awk '{if($1=="abxxxxb1") { print $3}}'

  #3 (permalink)  
Old 06-26-2009
sagii sagii is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 22
thanks but it is not working.i have output in one file please let me know how to read first line first column and third column.thanks
  #4 (permalink)  
Old 06-26-2009
rakesh_pagadala rakesh_pagadala is offline
Registered User
  
 

Join Date: May 2009
Location: hyderabad
Posts: 20
try this...
sed -n '3p' test | awk '{print $1 " " $3}'
  #5 (permalink)  
Old 06-26-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
Please post the command you typed and the output your received followed by the expected output after filtering or processing. We can gather from your posts that your are monitoring print queues in some detail but need to know what information you need from AIX to perform your role.
  #6 (permalink)  
Old 06-27-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
ksh - can use read with pipe:

lpstat | grep "^abxxxxb1 " | read queue dev status somefields

[ "$queue" = "" ] && print "no status for abxxxxb1" >&2 && exit 1

[ "$status" != "DOWN" ] && print "abxxxxb1 ok" && exit 0

print "abxxxxb1 is down"

General sh version to use read:

read queue dev status somefields <<EOF
$(lpstat | grep "^abxxxxb1 " )
EOF
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0