Visit Our UNIX and Linux User Community


reading from a screen


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers reading from a screen
# 1  
Old 04-23-2004
reading from a screen

Hi

There is a program running which displays output on the screen
I have to grep a particular string from that screen how do i do this

My problem is i'm running this program from a script which executes after every fifteen mins but sometimes it's happen that there is an error in the program which my script cannot recognise i wan't to trap this error in basic from the screen.

Pls help
# 2  
Old 04-23-2004
Quote:
Originally posted by Driver
I'm not sure I understand your problem, but my guess would be this: The program writes error messages to the standard error stream, as opposed to the standard output stream. Therefore, the grep utility will not ``see'' it, because it only reads the standard output.

The solution: Redirect the standard error stream to a file or to the standard output stream.

Code:
nils@nilsix:~> cat new.c
#include <stdio.h>

int
main(void) {
        fprintf(stderr, "Hello world\n");
        return 0;
}
nils@nilsix:~> cc new.c -o new
nils@nilsix:~> ./new | grep -v Hello  # grep does not ``see'' message
Hello world
nils@nilsix:~> ./new 2>&1 | grep -v Hello  # Redirect stderr to stdout
nils@nilsix:~> ./new 2>&1 | grep Hello
Hello world
nils@nilsix:~> echo $SHELL
/bin/bash
nils@nilsix:~>

(This does not work with (t)csh.)

Thanks for the reply but could you explain what you mean by standard error stream and standard output stream

Thanks
# 3  
Old 04-23-2004
This is what appears on my screen what
i want to do is whenever there is a coredump
I want to find the filename above that in this case
(UTX00120040423162459880586)
and rename that file

Next file to process: "UTX00120040423162448880584" (fetched from directory)
Rih: Rih PID 270201: Next file to Process: UTX00120040423162448880584
lpr: -h: unknown printer
Next file to process: "UTX00120040423162454880585" (fetched from directory)
Rih: Rih PID 270201: Next file to Process: UTX00120040423162454880585
lpr: -h: unknown printer
Next file to process: "UTX00120040423162459880586" (fetched from directory)
Rih: Rih PID 270201: Next file to Process: UTX00120040423162459880586
Memory fault(coredump)

Thanks
# 4  
Old 04-23-2004
Satyanarayang,

Reporting posts to the moderators is not allowed in bumping your question - please read the RULES .
# 5  
Old 04-23-2004
I agree RTM...

IF no one knows your answer... you may not get an answer.


Please dont abuse the rules..



In addition this whole thread has the smell of a homework question... also against the Forum Rules.

Forgive me if im wrong on the second count.



BTW, standard output is data sent to the screen which you can capture to a file > file.out, standard error is a method of handling undesired output from a script...

When you run a script you usu send standard error to a file, > file.err to save it for analysis or send it to /dev/null if you dont care about it.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #542
Difficulty: Medium
A globally scoped variable is invalid throughout the entire program.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

O/P same as on screen

#Random Scripts 4 #Desc: clear echo "1. To see all processes currently running on the system" echo "2. To kill any given process" echo "Choose between the two" read x case $x in "1")print `ps aux`;; "2") echo "Choose a process to be killed" read y check=`ps ax | grep... (1 Reply)
Discussion started by: targetshell
1 Replies

2. UNIX for Dummies Questions & Answers

Accidentally made a screen within a screen - how to move it up one level?

I made a screen within a screen. Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies

3. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

4. UNIX for Dummies Questions & Answers

Reading from Screen/Standard Output

Is it possible to read from the screen or standard output? If so, may I know how I can do this? For example, I have an application running which prints out the following on the screen: Starting tools from .image-tools... imagecontrol_1: SECS/GEM-capable version is running done cindy@pgunix... (2 Replies)
Discussion started by: sippingsoda
2 Replies

5. Solaris

Screen ultility help

Solaris 8/9/10: Pls tell me how to create a screen session with read/write/execute access to me (owner) and read access to other user to see what I am doing, Also tell me how can I transfer my ownership to some other user for read/write/execute access. (0 Replies)
Discussion started by: harpreetrekhi
0 Replies

6. OS X (Apple)

Virtual screen accessed by Screen Sharing

Hi, I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it. The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies

7. Programming

reading reading data from webpage

hi iam reading data from web page using request socket and curl socket. now my problem is some the web page containg data as a image so how can i read the data from a image. thank,inadvance. sree (3 Replies)
Discussion started by: phani_sree
3 Replies

8. UNIX for Dummies Questions & Answers

Help with screen

Hello everyone! I'm trying to figure out how to send commands from one screen to another. For example i wish to send a simple "ls -all" from screen #1 to screen #2, can it be done, and how? :confused: Thank you! (12 Replies)
Discussion started by: Gurth
12 Replies

9. Programming

clear screen

what is the syntax for clearing the screen in c ? when i tried "Clrscr()" the CC complier does not reconise it. please do tell me more about this. thanking you imma (6 Replies)
Discussion started by: immanuelgangte
6 Replies

10. Programming

How to clear screen

I searched the post and someone said to clear the screen in C, use printf("\033[2J"); ?? However, this doesn't work...typo or no. What is an equivalent command to 'CLS' in DOS/'clear' in UNIX to clear the screen and go to top of screen?? Thank you. (2 Replies)
Discussion started by: giannicello
2 Replies

Featured Tech Videos