Question about details for the whole machine


 
Thread Tools Search this Thread
Operating Systems Solaris Question about details for the whole machine
# 8  
Old 03-25-2013
Great!
I'll try that as soon as I get a chance.

Any idea on why the command I used: "vmstat 1 2 | cut b-77-78 | grep -v id"
was causing a hang up?

After I entered the command via a script, and before the cut and grep, it held up at a hash prompt {#} and then I had to enter "exit" and hit return.

Then it executed the cut and grep.

Very odd as the comment worked perfectly when entered manually on the command line
# 9  
Old 03-25-2013
I think you want to get rid of the unwanted lines BEFORE you cut.

And I think it's going to be more reliable to get the data (id or whatever) with cut -f to get the field you want.
Code:
$ vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0   3252  24724 416548 271716    0    0    80    18   26   50  0  0 99  1
 0  0   3252  24716 416548 271716    0    0     0     0   46   75  0  0 100  0

Code:
$ vmstat 1 2 | tail -2 | sed "s/  */ /g" | cut -d " " -f 16
99
100

This User Gave Thanks to hanson44 For This Post:
# 10  
Old 03-25-2013
Quote:
Originally Posted by hanson44
I think you want to get rid of the unwanted lines BEFORE you cut.

And I think it's going to be more reliable to get the data (id or whatever) with cut -f to get the field you want.
Code:
$ vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0   3252  24724 416548 271716    0    0    80    18   26   50  0  0 99  1
 0  0   3252  24716 416548 271716    0    0     0     0   46   75  0  0 100  0

Code:
$ vmstat 1 2 | tail -2 | sed "s/  */ /g" | cut -d " " -f 16
99
100

Actually, Where we are getting the "99" and the "100", I need the "100" only

In the end, I am working on a Solaris system where "top" is not native. And it's been...stuttering for lack of a better word.

So I'm trying to get at the idle value another way, and I only need the last value.

Marc
# 11  
Old 03-26-2013
Quote:
Originally Posted by Marc G
Any idea on why the command I used: "vmstat 1 2 | cut b-77-78 | grep -v id"
was causing a hang up?
There is absolutely no reason for this command to hang.
The cause would be a bug in your script or an issue with your environment.
It would help if you post your whole script content.

---------- Post updated at 07:59 ---------- Previous update was at 07:55 ----------

Quote:
Originally Posted by hanson44
Code:
$ vmstat 1 2 | tail -2 | sed "s/  */ /g" | cut -d " " -f 16
99
100

Beware that this is the Solaris forum while your vmstat output is from Linux or similar. They are slightly different.
Also, you probably mean tail -1, not tail -2.
This User Gave Thanks to jlliagre For This Post:
# 12  
Old 03-26-2013
Quote:
Originally Posted by jlliagre
There is absolutely no reason for this command to hang.
The cause would be a bug in your script or an issue with your environment.
It would help if you post your whole script content.
well, here is the entire script as it's a test of the command functionality:
Code:
/usr/bin/ksh
vmstat 1 2 > /usr/home/mgrma/testFile
# vmstat 1 2 | nawk 'NR==4{print $NF}'
# vmstat 1 2 | awk '{print $22}' | awk '/[0-9]/'
# vmstat 1 2 | cut -b77-78 | grep -v id >> /usr/home/mgrma/testFile
# sed '2' /usr/home/mgrma/testFile

Each of the commented lines is a different method I have tried, including recommendations from here. With each try, I can run the command from the command line with no issue.

But when I put it into the script and run it, I get a "#" prompt and have to type "exit"

Once I do, there is the expected delay for vmstat to do it's thing and I get the correct data. As you can see, I even tried piping it to a file to process in later commands.

---------- Post updated at 07:59 ---------- Previous update was at 07:55 ----------

Beware that this is the Solaris forum while your vmstat output is from Linux or similar. They are slightly different.
Also, you probably mean tail -1, not tail -2.[/QUOTE]

as for linux, here is a uname output of the environment:

bash-3.2# uname -a
SunOS UsrBox 5.10 Generic_147440-27 sun4u sparc SUNW,Sun-Fire-V240
bash-3.2#

I am sudo to the bash user.

Marc

---------- Post updated at 11:19 AM ---------- Previous update was at 11:04 AM ----------

Never mind...

I'm a moron!

I was using "#!/usr/bin/ksh"

not "#!/bin/ksh"

Sorry for the confusion!
# 13  
Old 03-26-2013
Quote:
Originally Posted by Marc G
as for linux, here is a uname output of the environment:

bash-3.2# uname -a
SunOS UsrBox 5.10 Generic_147440-27 sun4u sparc SUNW,Sun-Fire-V240
bash-3.2#
This wasn't directed to you but to hanson44.
Quote:
I was using "#!/usr/bin/ksh"

not "#!/bin/ksh"
Actually, #!/usr/bin/ksh would have been fine just like #!/bin/ksh, the real issue is you were lacking the shebang (#!).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

2. Linux

Unable to connect to Server machine from a client machine using ftp service

Hi, Could you please help me with the below issue.. I'm running RHEL6 OS on both server (192.168.0.10) and client machines (192.168.0.1). I'm trying to connect to server from the client machine using ftp service. I have installed vsftpd daemon on both the machines. I'm getting... (4 Replies)
Discussion started by: raosr020
4 Replies

3. UNIX for Advanced & Expert Users

FTP While transfering files to local machine to remote machine

Hi Am using unix Ksh Am getting the problem while transferring zero size files through the script . When i transfer zero size files from local machine to remote machine manually i can able to do it . My question its beause of zero size files am not able to transfer through script ? or its... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

4. UNIX for Dummies Questions & Answers

at -l doesnt give details of the scheduled job. How to get the details?

I have scheduled couple of shell scripts to run using 'at' command. The o/p of at -l is: $ at -l 1320904800.a Thu Nov 10 01:00:00 2011 1320894000.a Wed Nov 9 22:00:00 2011 1320876000.a Wed Nov 9 17:00:00 2011 $ uname -a SunOS dc2prcrptetl2 5.9 Generic_122300-54 sun4u sparc... (2 Replies)
Discussion started by: superparticle
2 Replies

5. Windows & DOS: Issues & Discussions

How to know machine details in windows through cmd

Hi, I want to print machine details in windows. In UNIX it is easily available by the command uname -X Is there any command like this in windows to get those details.. can anybody help me on this.. Thanks in advance. ~arup (1 Reply)
Discussion started by: arup1980
1 Replies

6. Shell Programming and Scripting

How to transfer files from unix machine to local machine using shell script?

Hi All.. Am new to Unix!! Am creating a shell script in which a scenario is like i have transfer the output file from unix machine (Server) to local directory (Windows xp). And also i have to transfer the input file from the local directory to Unix machine (Server) Any help from you... (1 Reply)
Discussion started by: vidhyaS
1 Replies

7. Shell Programming and Scripting

shell script to copy files frm a linux machine to a windows machine using SCP

I need a shell script to copy files frm a linux machine to a windows machine using SCP. The files keeps changing day-to-day. I have to copy the latest file to the windows machine frm the linux machine. for example :In Linux, On July 20, the file name will be 20.txt and it should be copied to... (3 Replies)
Discussion started by: nithin6034
3 Replies

8. Red Hat

To find the LATEST file from a dir on REMOTE machine and SCP to local machine?

Hi All, URGENT - Please help me form a scipt for this: I need the LATEST file from a dir on REMOTE machine to be SCP'd to a dir on local machine. (and I need to execute this from local server) I know that the below cmd is used to find the LATEST file from a dir. But this command is not... (3 Replies)
Discussion started by: me_ub
3 Replies

9. SCO

How to check memory details of a SCO UNIXWARE machine

Hi All, I want to check memory details and other hardware details of my SCO machine. can someone please share the command to do that? Thanks, Am (2 Replies)
Discussion started by: am_yadav
2 Replies
Login or Register to Ask a Question