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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"cut" doesn't supress unwanted fields

Status
Not open for further replies.

gosuc2000

Technical User
Jun 2, 2004
59
DE
Hi gurus,

I have only little experience in shell-programming, but
nevertheless, this problem is important for me to be solved.

Inside a script I want to extract one value out of one line from the vmstat -command via ssh to a remote system

vmstat -P under TRU64 UNIX prints dozends of lines about memory-usage, like vmstat -m under Linux).
The COMMANDLINE provides the correct result , like here:

# ssh -l root <remote-ip> vmstat -P|grep -e ''Memory =''|cut -d = -f 2

But things go wrong inside my script:
free=`ssh -l $user $1 vmstst -P|grep -e ''Memory =''|cut -d = -f 2`

(where $user=root and $1=IP-Addr. $free is where I want this one value to be stored)

What I get when I start my script is the whole pile of lines that vmstat -P prints out, as if I didn't use |cut .. at all.

Why does the command-line work correctly and why gets everything printed when I use the script ?

Any help is apreciated.
Thanks in advance for your time.

Regards,
Fred
 
Sorry, flames on me....

when comparing the text in my post with my script, I noticed I put the "|" -Symbol not at the correct place.

Maybe I just worked too long on hat, so sometimes you just don't see the easy things.

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top