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 4071
"j. del" <do*******@gmai l.com> wrote in message
news:23******** *************** ***@posting.goo gle.com... 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*******@gmai l.com> wrote in message
news:23******** *************** ***@posting.goo gle.com... 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.thi s.grad.com> wrote in message news:<111153327 5.67142@athnrd0 2>... 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.thi s.grad.com> wrote in message news:<111153327 5.67142@athnrd0 2>... 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.thi s.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 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, periodically, I see
"java.IO.Exception: There is no process to read data written to a
pipe" error message in my log file. Can anybody tell me in what cases
this error message could occur?
The other strange thing is that our customer would report...
|
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 ret ==
# do read
|
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 parameter to read(),
or until it hits EOF. I cannot find a way to return only the data that
the file object has immediately available.
If no data is available, blocking is OK.
The only workaround I can think of is to call select() in a loop,...
|
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 binary file
through a unix pipe to the program (cat file | prog) everything works
fine. However, when I feed data from a program, one that connects to an
open socket so that multiple files can be processed, across a unix pipe
(prog1 | prog) the...
|
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)
p.stdin.write("hostname\n")
however, it doesn't seem to work. I think the cmd.exe is catching it.
| |
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 process being piped from is still reading.
On both my Linux and OSX system, it seems that there's a large delay reading from stdin if the process being read from is still running, even if it's producing output to be read. It will wait until it...
|
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 easily, and
was wondering if anyone know of a guide to mapping simple uses of
command line programs to python.
For an example, the kind of thing I am thinking of are things like
(yes, this is horrible code).
# These are a run of a program I...
|
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 pipe, but if you
still use readline() wouldnt the Thread block too?
What i need to do is, create a process using subprocess.Popen, where
the subprocess outputs information on one line (but the info
continuesly changes and its always on the same...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |