I was wondering how to capture the output of an "interactive" command that is run...? I think "interactive" is the
word I'm looking for. For example, commands like "top" and "iftop"...
The One I'm trying to work with is "iftop". When you run "iftop" from the command line it begins a screen in the
terminal that shows the ethernet interfaces and their kbps, Tx, Rx, etc... I know "top" has an option that instead of top
updating the screen once every so many seconds it outputs one screen and the command exits.
I didn't see any Options like that for "iftop" though.
After you run the command, then hit Control-C/or 'Q' to exit the command it shows the following on the screen:
Is there anyway to capture that output (above)...?
I tried the usual way, and also tried redirecting stderr to stdout but it still didn't have anything in the variable after
it completed the command.
Here's what I tried that hasn't worked yet:(tried each one below, and not all at the same time obviously...)
I thought that since just setting the command to a variable, and since that variable was empty when I 'echoed' it, that it was
actually printing that to stderr but that hadn't worked either...
Anyone know if this is possible?
Any thoughts would be much appreciated!
Thanks in Advance,
Matt
---------- Post updated at 04:52 PM ---------- Previous update was at 04:38 PM ----------
So playing around a bit more with this I just tried using the "tee"command. This seemed to actually save some data from the command
but it mostly looked like jibberish...
Also, I couldn't just run the iftop command and either redirect or using tee and have the command just stop so I tried adding "pkill" in there
to stop the command right away since I didn't know the PID.
Here's the command I just tried: And here is the contents of "myOutput.txt" File:
The Output is good enough for what I need to do. But I just wanted to ask and make sure that doing it this
way wouldn't run into a problem at anytime...?
Cool thanks, I'll check that link out...
Luckily, I just recently had to do the same thing (i.e. removing the control codes), so I should be ok there...
Hi,
I have to redirect output of the command "perldoc perllocal" to new file which
contains all the perl module installed.
Currently using
perldoc perllocal >> mod_data
This does not contain all perl modules installed locally on machine, and each character is doubled.
Please... (3 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
BACK STORY:
I have a script build.py . (It's for creating the ISO file for a special edition of Swift Linux.) This build.py script executes the mintConstructor.py script that I use to modify the Regular Swift Linux ISO to get the special edition Swift Linux ISO. The lines of the script that... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi.
I have a copy-file script (and a move-file script) that I recently tried to make interactive. I tested the former on three files from a text list, and watched to see what would happen. As the cp command was in a while/do/done loop, there was no pause for input: it wrote the file from the... (2 Replies)
Hi,
I am trying to get the system RAM size from "top" command's output by the following but it is not working.
top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Good morning
I've searched the Forum but couldn't find what I'm searching for.
I'm executing a, for example pepe.sh within a script (hello.sh).
pepe.sh executes and expects an "enter".
How could i told it within hello.sh?
Thanks in advance for your help.
Regards (1 Reply)
Hi All,
I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel).
For my application:
<sar -U ALL>
CPU %user %nice %system %idle
...
10:58:04 0 153.10 0.00 38.76 0.00
10:58:04 1 3.88 0.00 4.26 ... (0 Replies)