Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data from a system call 1

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
Hi Gents,

I'm working with awk in a LINUX 7.2 environment.

In an awk execution, I get a printer id and print job number. I want to get the "rank" information on the job from the execution of an lpq statement.

(The lpq data looks like: 1st root 4 .bash_profile 240 bytes)

I've tried several (unsuccessful) methods of getting the data, including putting the output of the data to a file.

My last attempt was:

system("RankLine=`/usr/bin/lpq -P" PrintrID " " JOBNBR " | grep bytes`;export RankLine")

I thought that by exporting the data I could use the ENVIRON parameter to access the data. This approach doesn't work as I think it because it's a different shell execution.

How do you access data from a system call within awk?

Desperately,

gawker [bugeyed]

 
cmd="/usr/bin/lpq -P " PrintrID " " JOBNBR

cmd | getline lpqOUTPUT; close(cmd);

#---------------
# parse out the lpqOUTPUT the way you want it
#
 
Thanks vgersh99,

Your suggestion was exactly what I needed.

gawker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top