Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to write to stdin of another program (program A -> [stdin]program B) Post 302190772 by vvaidyan on Wednesday 30th of April 2008 12:36:39 PM
Old 04-30-2008
How to write to stdin of another program (program A -> [stdin]program B)

Hi,
Program A: uses pipe()

I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:

* child
-> dup2(fd[1], STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);

* parent
-> char line[100];
-> read(fd[0], line, 100);


Question:
---------
How to write to stdin of PROGRAM B from PROGRAM A?
* should I use a different pipe?
* how to I read stdin in PROGRAM B? using cin?

Thanks in advance,
Vivek
 

10 More Discussions You Might Find Interesting

1. Programming

How to write to stdin of another program (program A -> [stdin]program B)

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question: ---------... (1 Reply)
Discussion started by: vvaidyan
1 Replies

2. Programming

How to clear the content of a pipe (STDIN) after it is written to another program?

PROGRAM A <-> PROGRAM B PROGRAM A sends data as STDIN ro PROGRAM B and when PROGRAM B is executed from PROGRAM A, it sends output back to PROGRAM A. This is implemented using 2 pipes (fd1 & fd2). The above process happens in a loop and during the second run, the previous data that had been... (10 Replies)
Discussion started by: vvaidyan
10 Replies

3. Programming

C++ How to use pipe() & fork() with stdin and stdout to another program

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question:... (2 Replies)
Discussion started by: vvaidyan
2 Replies

4. Programming

A program to trace execution of another program

Hi, I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally. If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies

5. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

6. Shell Programming and Scripting

how to write next line program

Hi, I am having an input file which contains a group of words,if one specific word comes which goes to next line. example: input file===> shashi country= india comapny= none shashi shashi company= NONE shashi=my name output===> shashi country= india comapny= none shashi shashi... (6 Replies)
Discussion started by: hegdeshashi
6 Replies

7. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

8. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

9. Shell Programming and Scripting

How do you write this program/script?

I need help with the following. 1) Write a program in any language that takes a single integer array parameter and returns the decimal average of the input values. 2) Write a program, in any language, that prints the integers from 1 to 10, along with a cumulative sum of the integers printed... (1 Reply)
Discussion started by: sqa4life
1 Replies

10. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies
0LAUNCH(1)																0LAUNCH(1)

NAME
0launch -- download and run programs by URL SYNOPSIS
0launch [OPTION]... PROGRAM [ARG]... DESCRIPTION
0launch runs the given program. PROGRAM is either a URL in the form `http://site/program.xml' or a local path name like `/path/to/pro- gram.xml'. If the program is not already on your computer, 0launch downloads information about which versions are available, and lets you choose one to download. It will also (automatically) do the same for any libraries the program needs. Note that much of the functionality that was originally in 0launch has now moved to 0install(1). 0launch PROGRAM ARGS is roughly equivalent to 0install run PROGRAM ARGS See the 0install(1) man-page for more information. EXAMPLES
When a program is available using 0launch, it will have an associated URL. To run the program, simply invoke 0launch with this as an argu- ment: 0launch http://rox.sourceforge.net/2005/interfaces/Edit The first time you do this, details about the program are downloaded and cached, and you will be prompted to confirm the versions to use. In future, the program will run directly from the cache without confirmation. To check for new versions: 0launch --refresh http://rox.sourceforge.net/2005/interfaces/Edit To avoid having to keep typing the full URI, use the 0alias(1) command to create shortcuts to run your programs. COMMAND-LINE OPTIONS 0launch takes many of the same options as "0install run". This page just lists the differences: -d, --download-only Deprecated. Use "0install download" instead. -f, --feed Deprecated. Use "0install add-feed" or "0install remove-feed" instead. --get-selections Deprecated. Use "0install select" instead. -i, --import Deprecated. Use "0install import" instead. -l, --list Deprecated. Use "0install list" instead. --select-only Deprecated. Use "0install select" instead. --set-selections=FILE Deprecated. Just give FILE as the PROGRAM. --show Deprecated. Use "0install select" instead. DEBUGGING TIPS
To debug 0launch itself, use the --verbose and --console options. For example: $ 0launch -vvc http://myprog To trace or debug programs run by 0launch, use the --wrapper option. For example, to run myprog --help, displaying all calls to open(2): $ 0launch --wrapper="strace -e open" http://myprog --help If your program is interpreted (e.g. a Python program), and you wish to debug the interpreter running it, you can do it like this: $ 0launch --wrapper="gdb --args python" http://myprog --help FILES
Configuration files (see freedesktop.org basedir spec): ~/.config/0install.net/injector/global Global configuration settings. ~/.config/0install.net/injector/trustdb.xml List of trusted keys. ~/.config/0install.net/injector/interfaces Per-interface settings, and extra feeds. Cached data (can be re-downloaded if lost): ~/.cache/0install.net/interfaces Downloaded cached feed files. ~/.cache/0install.net/implementations Downloaded cached implementations, indexed by manifest digest. See the 0store(1) man page for more information. LICENSE
Copyright (C) 2011 Thomas Leonard. You may redistribute copies of this program under the terms of the GNU Lesser General Public License. BUGS
Please report bugs to the developer mailing list: http://0install.net/support.html AUTHOR
Zero Install was created by Thomas Leonard. SEE ALSO
0install(1), 0alias(1), 0store(1) The Zero Install web-site: http://0install.net Thomas Leonard 2011 0LAUNCH(1)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy