473,404 Members | 2,137 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,404 software developers and data experts.

How do I read from, and write to, a bash pipe in C++?

Sean Pedersen
Is it always characters, or can it be data?
I'd also like to know when my program is being run directly, then it will behave differently.
A great example of the input behavior desired is demonstrated through use of nano. Here's what I'm looking for:
Expand|Select|Wrap|Line Numbers
  1. int main(int argc, char * argv) {
  2.     int len = 0;
  3.     int buffer[] = new int[1024];
  4.     while (!timeout() && len < 1024)
  5.         len += getPipe(buffer, len, 1024-len);
  6.     if (len == 0) doNoPipe();
  7. }
...where timeout(), getPipe(), and doNoPipe() are my functions.
Dec 3 '10 #1
0 1156

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

Similar topics

21
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default...
13
by: j. del | last post by:
I am just beginning to write programs... and my first task that I have set myself is to write a little program that will generate cryptic bywords from a source of text. A cryptic byword is...
1
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public...
2
by: Luis Mendes | last post by:
How can I read and write images to SQL server to a field with the type "image". Can´t make DataBound work. Thank's in advance, Luis
12
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The...
23
by: asit dhal | last post by:
hello friends, can anyone explain me how to use read() write() function in C. and also how to read a file from disk and show it on the monitor using onlu read(), write() function ??????
9
by: vineeth | last post by:
Hello all, I have come across a weird problem, I need to determine the amount of bytes read from a file, but couldn't figure it out , My program does this : __ file = open("somefile") data =...
2
by: Rudy Gevaert | last post by:
Hi, I have written an perl program that read from stdin: while(<STDIN>) { chomp do_it($_); } Data is fed to it via a pipe:
8
by: Peter Otten | last post by:
hofer wrote: for line in open("file"): # read from file try: a, b = map(int, line.split(None, 2)) # remove extra columns, # convert to integer except ValueError: pass # remove comments,...
0
by: dblack305 | last post by:
Im having difficulty writing this program, basically im trying to use a Pipe to read from one command and write to another. For this example i have been trying ls | sort -r . Its executing the ls...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.