473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Reading from Stdin and echo to Stderr

I have a java program that writes to Stdout. I have to write a C program that reads from Stdin and echoes to Stderr. I have never dealed with C before so i was wondering if someone could help me out???

Thank you!
Doug
Jul 29 '08 #1
4 2905
For example if my java program write "hello world" to stdout then how would I get it to read that in and echo it to stderr?

I am pipelining the two,

The jar would contain essentially:

System.out.println("hello world");

I am very confused as to how the two programs would intercommunicate on teh pipeline, any help is helpful!

Doug
Jul 29 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Use scanf or fscanf to read stdin and fprintf to output to stderr.
Aug 3 '08 #3
gpraghuram
1,275 Expert 1GB
For example if my java program write "hello world" to stdout then how would I get it to read that in and echo it to stderr?

I am pipelining the two,

The jar would contain essentially:

System.out.println("hello world");

I am very confused as to how the two programs would intercommunicate on teh pipeline, any help is helpful!

Doug
You can do it this way...
$ <Java program> | <Your C Executable>

Inside the C executable you have to use the idea told by weaknessforcats

Thanks
Raghuram
Aug 4 '08 #4
JosAH
11,448 Expert 8TB
I am pipelining the two,

The jar would contain essentially:

System.out.println("hello world");
If you want to you can handle this all in Java; write a small driver class:

Expand|Select|Wrap|Line Numbers
  1. public class Wrapper {
  2.    public static void main(String[] args) {
  3.       System.setOut(System.err); // what you want
  4.       YourOriginalMainClass.main(args);
  5.   }
  6. }
  7.  
Start up your JVM using the class above and voila.

kind regards,

Jos
Aug 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bernhard Kuemel | last post by:
Hi! I want to read/write commands and program input to/from /bin/bash several times before I close the stdin pipe. However, reading from cat hangs unless I first close the stdin pipe. <?php...
4
by: Jan Knop | last post by:
Hello I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ? Has anyone done it using Winsock ?
0
by: Brano Zarnovican | last post by:
Hi ! I'd like to init curses and still have working Python interactive command line. I found that you can replace stdin/stdout/stderr like this: #!/usr/bin/python -i import curses import...
1
by: Scott Shaw | last post by:
Hi all, I was wondering if you could help out with this problem that I am having. What I am trying to do is detect keyboard input in a while loop without halting/pausing the loop until the key is...
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
20
by: sahukar praveen | last post by:
Hello, I have a question. I try to print a ascii file in reverse order( bottom-top). Here is the logic. 1. Go to the botton of the file fseek(). move one character back to avoid the EOF. 2....
6
by: ccdrbrg | last post by:
What is the best way to protect stdin within a library? I am writing a terminal based program that provides plugin capability using the dlopen() API. Sequencing program commands (typed) and...
3
by: joshuawilsonster | last post by:
All, I'm hoping you can provide some help. I have opened a temporary file, written to it, verified the correct amount was written, done freopen() for the file to stdin, then try read the...
2
by: kimonp | last post by:
I am running on windows XP with a fresh install of wamp5 (1.7.2) and mediawiki. I am trying to call a perl function from within php using proc_open. The perl script is being executed and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.