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
get output in each cell from shell script sophos Shell Programming and Scripting 3 04-23-2009 10:40 PM
have a shell script done in pl/sql and want output in html arobert Shell Programming and Scripting 2 12-13-2008 01:56 AM
Shell Script Output sharpi03 Shell Programming and Scripting 4 09-20-2008 12:16 AM
Shell script getting input from output aspect_p Shell Programming and Scripting 1 03-11-2008 07:37 AM
redirecting SQL output from within a shell script soliberus Shell Programming and Scripting 2 11-23-2007 08:29 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-16-2009
Thireus Thireus is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 3
[How To?] Run shell script and get output into another shell.

Hi guys,

I have a simple question, I want to store the output of the following command:

Quote:
sudo iotop -t 0 -C 3 | grep "load: "
As you can see it is running all the time, and we get a new line every 3sec.

I just want to store these new lines into a single variable, so I can use it into a script.

To clear the screen, and do not print lines after the others when iotop is running just delete "- C".

I DO NOT WANT TO STORE THE OUTPUT ON THE DRIVE!!!
I DO NOT WANT TO KILL IOTOP, IT MUST BE RUNNING ALL THE TIME IN BACKGROUND!!!

The idea is to do not write on the drive! Just store the output into a single variable called $Activity.

For example:


Code:
Activity=$(sudo iotop -t 0 3 | grep "load: ") &

While $Activity... do blahblah... done

But the fact is that nothing can be stored into Activity
So I have tried to know if something can be done to read the last output of a specified PID. But I need help on that point too :-/ I don't know how to do it.

Please help...

---------- Post updated at 09:57 AM ---------- Previous update was at 02:02 AM ----------

Ok, here is my code:


Code:
sudo iotop -t 0 -C 3 | grep "load: " | script.sh

script.sh:


Code:
#!/bin/sh

  while read data
  do
      echo "[$(date +"%D %T")] $data" >> log_activity.txt
  done

But nothing is read
 

Bookmarks

Tags
activity, drive, pid, variable

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 09:37 AM.


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