awk '{if ($1 == "State:" && $2 == "Okay") {print system("uname -n")}}'
---------- Post updated at 01:20 AM ---------- Previous update was at 01:19 AM ----------
it is printing uname -n instead of printing the output of the command
awk '{if ($1 == "State:" && $2 == "Okay") {print system("uname -n")}}'
---------- Post updated at 01:20 AM ---------- Previous update was at 01:19 AM ----------
it is printing uname -n instead of printing the output of the command
You could use:
{ system( "uname -n" ) }
Without print. The stdout will go to your terminal.
If you need to manipulate that information further,
you could save it in an awk variable:
{ "uname -n" | getline sn }
The machine name will be stored in the sn variable.
awk '{if ($1 == "State:" && $2 == "Okay") {"uname -n"|getline sn; print $sn}}'
tried this it is not working.
awk '{if ($1 == "State:" && $2 == "Okay") {system( "uname -n" )}}'
this also is not working.
I work in KSH
In the first case it should be:
print sn
Note that there is no dollar sign.
If the expression $1 == "State:" && $2 == "Okay"
evaluates to true and the uname command is accessible and executable, the second one should work.
#metastat -t|grep State|awk '{if ($1 == "State:" && $2 == "Okay") {"uname -n"|getline sn; print sn}}'
awk: syntax error near line 1
awk: illegal statement near line 1
# metastat -t|grep State |awk '{if ($1 == "State:" && $2 == "Okay") {system( "uname -n" )}}'
# metastat -t|grep State |awk '{if ($1 == "State:" && $2 == "Okay"){print "Hi"}}'
Hi
Hi
Hi
Hi
# metastat -t|grep State |awk '{if ($1 == "State:" && $2 == "Okay"){print "Hi"}}'
Hi
Hi
Hi
Hi
#
copied from terminal..
---------- Post updated at 06:23 AM ---------- Previous update was at 06:21 AM ----------
yes uname works .
Could you post an example output from memstat -t
?
---------- Post updated at 01:35 PM ---------- Previous update was at 12:40 PM ----------
You should use nawk or /usr/xpg4/bin/awk on Solaris.
# memstat -t
ksh: memstat: not found
XXXXXX:/ # uname -n
XXXXXX
---------- Post updated at 08:09 AM ---------- Previous update was at 08:07 AM ----------
nawk works
thanks a lot
I think radoulov meant you to post the output from the command:
metastat -t
Typed from the command line as user root with no pipes or other filtering.
Yes,
of course.
If the OP posts the output of memstat,
we could provide a more concise solution.