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
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)
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)
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)
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)
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)
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)
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)
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)
#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
LEARN ABOUT V7
putc
PUTC(3S)PUTC(3S)NAME
putc, putchar, fputc, putw - put character or word on a stream
SYNOPSIS
#include <stdio.h>
int putc(c, stream)
char c;
FILE *stream;
putchar(c)
fputc(c, stream)
FILE *stream;
putw(w, stream)
FILE *stream;
DESCRIPTION
Putc appends the character c to the named output stream. It returns the character written.
Putchar(c) is defined as putc(c, stdout).
Fputc behaves like putc, but is a genuine function rather than a macro. It may be used to save on object text.
Putw appends word (i.e. int) w to the output stream. It returns the word written. Putw neither assumes nor causes special alignment in
the file.
The standard stream stdout is normally buffered if and only if the output does not refer to a terminal; this default may be changed by set-
buf(3). The standard stream stderr is by default unbuffered unconditionally, but use of freopen (see fopen(3)) will cause it to become
buffered; setbuf, again, will set the state to whatever is desired. When an output stream is unbuffered information appears on the desti-
nation file or terminal as soon as written; when it is buffered many characters are saved up and written as a block. Fflush (see
fclose(3)) may be used to force the block out early.
SEE ALSO fopen(3), fclose(3), getc(3), puts(3), printf(3), fread(3)DIAGNOSTICS
These functions return the constant EOF upon error. Since this is a good integer, ferror(3) should be used to detect putw errors.
BUGS
Because it is implemented as a macro, putc treats a stream argument with side effects improperly. In particular `putc(c, *f++);' doesn't
work sensibly.
PUTC(3S)