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 basically a ceaser
cypher but with randomly assigned letters rather than just shifted
down by a value. So.. I am thinking that the BSD fortune game for the
gnixes is a good source for the text to cypher. HOWEVER.. I am not
sure how to read data in from another source into a C++ program..
I would like to do ...
$fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a
bash pipe?
Help?
joshua 13 3998
"j. del" <do*******@gmail.com> wrote in message
news:23**************************@posting.google.c om... 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 basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in from another source into a C++ program..
I would like to do ... $fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a bash pipe?
Help?
joshua
I've never heard of a "bash pipe", (or many of those other terms, either).
Isn't that something we used to smoke back in the '70s? :-)
But I believe that when you "pipe" data into an application, it simply
appears in the standard input stream. Look up how to use std::cin. I think
that's the answer.
-Howard
j. del wrote: 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 basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in from another source into a C++ program..
I would like to do ... $fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a bash pipe?
Help?
This has nothing to do with C++ language. Piping of command outputs is
done at the OS level and the 'crypticbyword' simply gets the 'fortune's
output as its standard input. Please get a book on programming your OS
and read about pipes, or post to a newsgroup that deals with your OS.
V
"j. del" <do*******@gmail.com> wrote in message
news:23**************************@posting.google.c om... and have it output the cryptic byword. How does one read data from a bash pipe?
AFAIK, the data put into the pipe is just written to the standard input stream
(cin) for the next program.
- JFA1
j. del wrote: 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 basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in from another source into a C++ program..
I would like to do ... $fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a bash pipe?
Help?
int main(int argc, char *argv[]) in the second program I suppose.
--
Ioannis Vranos http://www23.brinkster.com/noicys
Ioannis Vranos <iv*@remove.this.grad.com> wrote in message news:<1111533275.67142@athnrd02>... j. del wrote:
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 basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in from another source into a C++ program..
I would like to do ... $fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a bash pipe?
Help?
int main(int argc, char *argv[]) in the second program I suppose.
This looks like what I'm looking for. The question could be phrased
'how to read data from stdin as a sort of argument' maybe. I don't
think it has fsckall to do with the OS, since Win32 shells have pipes
as well as C, or any other command line. If I had the money for a
book, I would buy one. I am sure that I will. Thank you Ioannis.
J
read
"I don't think it has fsckall to do with the OS, since Win32 shells
have pipes as well as C, or any other command line."
as "since Win32 shells have pipes as well as C shell"
for clarification.
Ioannis Vranos <iv*@remove.this.grad.com> wrote in message news:<1111533275.67142@athnrd02>... j. del wrote:
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 basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in from another source into a C++ program..
I would like to do ... $fortune | crypticbyword
and have it output the cryptic byword. How does one read data from a bash pipe?
Help?
int main(int argc, char *argv[]) in the second program I suppose.
This looks like what I'm looking for. The question could be phrased
'how to read data from stdin as a sort of argument' maybe. I don't
think it has fsckall to do with the OS, since Win32 shells have pipes
as well as C, or any other command line. If I had the money for a
book, I would buy one. I am sure that I will. Thank you Ioannis.
J
j. del wrote: read
"I don't think it has fsckall to do with the OS, since Win32 shells have pipes as well as C, or any other command line."
as "since Win32 shells have pipes as well as C shell"
for clarification.
int main(int argc, char *argv[]) in the second program I suppose.
This looks like what I'm looking for. The question could be phrased 'how to read data from stdin as a sort of argument' maybe. I don't think it has fsckall to do with the OS, since Win32 shells have pipes as well as C, or any other command line. If I had the money for a book, I would buy one. I am sure that I will. Thank you Ioannis.
Actually this has not anything to do with cin (standard input stream,
usually the keyboard).
This is how to get the command line arguments in a program. If argc!=0,
argv[0] is the name of the program itself as used in the command line,
argv[1] the first argument etc, and argc the total amount of them.
argv[argc]=='\0' ('\0' has the value 0 by the way).
So if you create a program test and you do:
C:\c>test -a -v
you get:
argv[0]== "test"
argv[1]== "-a"
argv[2]== "-v"
argv[3]== "" (or '\0' or 0).
--
Ioannis Vranos http://www23.brinkster.com/noicys
"Ioannis Vranos" <iv*@remove.this.grad.com> wrote... [..] So if you create a program test and you do:
C:\c>test -a -v
you get:
argv[0]== "test"
There is no guarantee on that. It can be "" just as well.
argv[1]== "-a" argv[2]== "-v" argv[3]== "" (or '\0' or 0).
Actually there is no "or" about it. argv[argc] is 0. Not "", not
'\0', null. See the Standard, the subclause about the 'main' function.
And by the way, C strings do not compare very well with the equality
operator. Use something different next time please. For example,
<<argv[1] points to "-a">>. Otherwise newbies will try
if (argv[0]== "-a")
and complain about it when it doesn't work with reference to your
liberal use of operator==.
V
Ioannis Vranos schrieb: j. del wrote:
read "I don't think it has fsckall to do with the OS, since Win32 shells have pipes as well as C, or any other command line."
as "since Win32 shells have pipes as well as C shell"
for clarification. int main(int argc, char *argv[]) in the second program I suppose.
This looks like what I'm looking for. The question could be phrased 'how to read data from stdin as a sort of argument' maybe. I don't think it has fsckall to do with the OS, since Win32 shells have pipes as well as C, or any other command line. If I had the money for a book, I would buy one. I am sure that I will. Thank you Ioannis.
Actually this has not anything to do with cin (standard input stream, usually the keyboard).
Yes it has. The question was about pipes. While C++ doesn't know about
pipes, it knows about standard input, accessible via std::cin. And
standard input happens to be exactly where the data piped into a program
by the shell ends up. "Usually the keyboard" is a little imprecise. At
the very least there's a line buffer between the keyboard and stdin.
More likely it's some kind of terminal or console device or mechanism.
A console window in Windows is one such mechanism. Either way, the
keyboard is not the only possible origin of what arrives at stdin; as
far as C++ is concerned, stdin is simply a source of input data.
This is how to get the command line arguments in a program. If argc!=0, argv[0] is the name of the program itself as used in the command line, argv[1] the first argument etc, and argc the total amount of them. argv[argc]=='\0' ('\0' has the value 0 by the way).
So if you create a program test and you do:
C:\c>test -a -v
you get:
argv[0]== "test" argv[1]== "-a" argv[2]== "-v" argv[3]== "" (or '\0' or 0).
Correct for program arguments. When the OP wrote "sort of argument",
that didn't necessarily refer to argv.
Cheers,
Malte
"Malte Starostik" <ma***@starostik.de> wrote in message
news:42********@olaf.komtel.net... int main(int argc, char *argv[]) in the second program I suppose.
This looks like what I'm looking for. The question could be phrased 'how to read data from stdin as a sort of argument' maybe. I don't think it has fsckall to do with the OS, since Win32 shells have pipes as well as C, or any other command line. If I had the money for a book, I would buy one. I am sure that I will. Thank you Ioannis.
Actually this has not anything to do with cin (standard input stream, usually the keyboard).
Yes it has. The question was about pipes.
The question was about pipes, but you misssed the point. The proposed
*answer* by Ioannis was using command-line arguments, and Victor pointed out
that that had nothing to to with cin (which is how piped-in data can be
read, via standard input).
-Howard
Howard wrote: [...] The proposed *answer* by Ioannis was using command-line arguments, and Victor pointed out
No... Ioannis actually pointed it to himself, I guess. I just caught
a couple of other discrepancies in his post.
that that had nothing to to with cin (which is how piped-in data can be read, via standard input).
V
Victor Bazarov wrote: No... Ioannis actually pointed it to himself, I guess. I just caught a couple of other discrepancies in his post.
And I got a head-ache. :-)
Actually I made a mistake, piping passes a program's standard output to
the other's standard input (cin in C++). I do not how I got confused and
thought that the output is passed to char *argv[] somehow.
--
Ioannis Vranos http://www23.brinkster.com/noicys
"Ioannis Vranos" <iv*@remove.this.grad.com> wrote in message
news:1111721871.123532@athnrd02... Victor Bazarov wrote:
No... Ioannis actually pointed it to himself, I guess. I just caught a couple of other discrepancies in his post.
And I got a head-ache. :-)
Actually I made a mistake, piping passes a program's standard output to the other's standard input (cin in C++). I do not how I got confused and thought that the output is passed to char *argv[] somehow.
Maybe from smoking that bash pipe...? ;-)
-Howard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jenny |
last post by:
Hi,
I have a java socket program running on AIX 4.3.3.0 platform. It
opens a socket and sends data to our customer over a leased fractional
T1 line. The line is always connected. However,...
|
by: Jim |
last post by:
Hi,
I am trying to figure out a way to implement a timeout along with a
read() call on an open file. It only has to work on linux,
for now I am trying:
ret = select.select( ,,, timeout )
if...
|
by: Peter Ammon |
last post by:
I would like to read from a pipe in which data may arrive slowly. From
experimenting, it looks like os.read() will block until it returns the
maximum amount of data you asked for, in the second...
|
by: lpe540 |
last post by:
Hi,
I'm having trouble using istream to read in a file in its entirety on
UNIX. I've written a dummy program that essencially reads in a file
from stdin and writes it out to a file. When I cat a...
|
by: jas |
last post by:
Hi,
I would like to start a new process and be able to read/write from/to
it. I have tried things like...
import subprocess as sp
p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
|
by: collinm |
last post by:
hi
we use linux and c language
under bash i do
echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2
that send command to a led display (alpha sign communication)
|
by: ShawnD |
last post by:
I'm having some issues when trying to read input off of a pipe using a python script. I'm trying to process packet data from tcpdump in real-time, so it's a filter that needs to read data while the...
|
by: 4zumanga |
last post by:
I have a bunch of really horrible hacked-up bash scripts which I would
really like to convert to python, so I can extend and neaten them.
However, I'm having some trouble mapping some constructs...
|
by: placid |
last post by:
Hi all,
I have been looking into non-blocking read (readline) operations on
PIPES on windows XP and there seems to be no way of doing this. Ive
read that you could use a Thread to read from the...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |