Hello, I'm new to c - so sorry if this is off topic here, please advice
at least where should i ask... ;)
I have a program in c which is working fine, it reads everything from
pipe, modifies output data a bit and writes to stdout.
When it is executed without parameters, program works fine. But what if
I'd like to pass some extra configuration parameters to my program?
1. c:\> pipetest < file_in > file_out // this works
2. c:\> pipetest /parameter < file_in // also works, writes
file_in and parameters to stdout
3. c:\> pipetest /parameter < file_in > file_out // nothing happens !?
Thanks anyone for kind advice and a nice day to all,
Y.
// pitest.c
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(int argc,char *argv[]) {
int ch,i;
for (i = 1; i < argc; i++) {
printf("%s\n",a rgv[i]);
}
setmode(fileno( stdin), O_BINARY);
setmode(fileno( stdout), O_BINARY);
ch=getc(stdin);
while (!feof(stdin)) {
putc(ch,stdout) ;
}
}
// ------- 7 2239
<ja***********@ seznam.cz> wrote in message news:43******** @x-privat.org... Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
I have a program in c which is working fine, it reads everything from pipe, modifies output data a bit and writes to stdout.
When it is executed without parameters, program works fine. But what if I'd like to pass some extra configuration parameters to my program?
1. c:\> pipetest < file_in > file_out // this works 2. c:\> pipetest /parameter < file_in // also works, writes file_in and parameters to stdout 3. c:\> pipetest /parameter < file_in > file_out // nothing happens !?
Thanks anyone for kind advice and a nice day to all, Y.
// pitest.c #include <stdio.h> #include <fcntl.h> #include <io.h>
int main(int argc,char *argv[]) { int ch,i; for (i = 1; i < argc; i++) { printf("%s\n",a rgv[i]); } setmode(fileno( stdin), O_BINARY); setmode(fileno( stdout), O_BINARY); ch=getc(stdin); while (!feof(stdin)) { putc(ch,stdout) ; } } // -------
Shouldn't the getc() call be inside the while loop?
"ja***********@ seznam.cz" <ja***********@ seznam.cz> wrote in
news:43******** @x-privat.org: Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
I have a program in c which is working fine, it reads everything from pipe, modifies output data a bit and writes to stdout.
When it is executed without parameters, program works fine. But what if I'd like to pass some extra configuration parameters to my program?
1. c:\> pipetest < file_in > file_out // this works 2. c:\> pipetest /parameter < file_in // also works, writes file_in and parameters to stdout 3. c:\> pipetest /parameter < file_in > file_out // nothing happens !?
Thanks anyone for kind advice and a nice day to all, Y.
// pitest.c #include <stdio.h> #include <fcntl.h> #include <io.h>
int main(int argc,char *argv[]) { int ch,i; for (i = 1; i < argc; i++) { printf("%s\n",a rgv[i]); } setmode(fileno( stdin), O_BINARY); setmode(fileno( stdout), O_BINARY); ch=getc(stdin); while (!feof(stdin)) { putc(ch,stdout) ; } }
a) Case #1 has no arguments to print because everything from the '<' over
is not passed to your program.
b) Case #3 will write "/parameter" to file_out, because that's where
you've redirected stdout, STUPID.
c) Your program will NOT copy stdin to stdout correctly; it will just
copy the first byte from stdin over and over until you stop the program,
you DUMBASS.
d) You are a fucking moron. Forget C and go play with dolls or
something.
Hake <ha***@third.fl oor> wrote: b) Case #3 will write "/parameter" to file_out, because that's where you've redirected stdout, STUPID.
(unwarranted flame snipped)
I would suggest demonstrating some civility, lest you be dealt with in
like fashion the next time a bug appears in your code. Not everyone
has the luxury of skipping the "beginning programmer" stage as you
apparently have.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome. ja***********@s eznam.cz <ja***********@ seznam.cz> wrote: Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
It isn't very topical; comp.unix.progr ammer is a good place to go
(assuming, perhaps incorrectly, that you are using a flavor of Unix).
You managed not to be totally off-topic, however...
// pitest.c #include <stdio.h> #include <fcntl.h> #include <io.h>
int main(int argc,char *argv[]) { int ch,i; for (i = 1; i < argc; i++) { printf("%s\n",a rgv[i]); } setmode(fileno( stdin), O_BINARY); setmode(fileno( stdout), O_BINARY); ch=getc(stdin); while (!feof(stdin)) { putc(ch,stdout) ; } }
Don't do it like that.
while( (ch=getc(stdin) ) != EOF ) {
putc( ch, stdout );
}
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Hake wrote: "ja***********@ seznam.cz" <ja***********@ seznam.cz> wrote in news:43******** @x-privat.org:
Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
I have a program in c which is working fine, it reads everything from pipe, modifies output data a bit and writes to stdout.
When it is executed without parameters, program works fine. But what if I'd like to pass some extra configuration parameters to my program?
1. c:\> pipetest < file_in > file_out // this works 2. c:\> pipetest /parameter < file_in // also works, writes file_in and parameters to stdout 3. c:\> pipetest /parameter < file_in > file_out // nothing happens !?
Thanks anyone for kind advice and a nice day to all, Y.
// pitest.c #include <stdio.h> #include <fcntl.h> #include <io.h>
int main(int argc,char *argv[]) { int ch,i; for (i = 1; i < argc; i++) { printf("%s\n",a rgv[i]); } setmode(fileno( stdin), O_BINARY); setmode(fileno( stdout), O_BINARY); ch=getc(stdin); while (!feof(stdin)) { putc(ch,stdout) ; } }
a) Case #1 has no arguments to print because everything from the '<'
over is not passed to your program.
this point was clear to me :) b) Case #3 will write "/parameter" to file_out, because that's where you've redirected stdout, STUPID.
Oh no, right! I must admit you are right :( :( I'm really a dumb :( What
a contretemps.... c) Your program will NOT copy stdin to stdout correctly; it will just copy the first byte from stdin over and over until you stop the program, you DUMBASS.
The program I pasted here was wrong, original of my program is longer
and it was not point to bore anyone with that, when that worked. My loop
is working... my only mistake was I forgot to leave fgetc inside loop -
in original it's there of course... :) d) You are a fucking moron. Forget C and go play with dolls or something.
And you are a monkey, not a human :) btw. I prefer trainspotting before
playing with dolls... ;) But in some rare cases I need to make some
handy program. I'm not a programmer (as everyone yet noticed:)
Anyway, thank you for help, you are a bit rude, but you helped me, and
that was what I really needed :D btw. the question *wasn't* "what you
thing about my IQ", so you could have left the off topic notes for
yourself... ;) But I must admit that I have showed up myself pretty bad :(
J.
Christopher Benson-Manica wrote: ja***********@s eznam.cz <ja***********@ seznam.cz> wrote:
Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
It isn't very topical; comp.unix.progr ammer is a good place to go (assuming, perhaps incorrectly, that you are using a flavor of Unix). You managed not to be totally off-topic, however...
Thank you ;)
Don't do it like that.
while( (ch=getc(stdin) ) != EOF ) { putc( ch, stdout ); }
Thank you for kind reply, I screwed "copy and paste" operation :(
The piece of program I pasted here was wrong, original of my program is
longer and it was not point to bore anyone with that, when that worked.
My loop is working... my only mistake was I forgot to leave fgetc inside
loop - in original it's there of course... :)
J.
Barry wrote: <ja***********@ seznam.cz> wrote in message news:43******** @x-privat.org...
Hello, I'm new to c - so sorry if this is off topic here, please advice at least where should i ask... ;)
I have a program in c which is working fine, it reads everything from pipe, modifies output data a bit and writes to stdout.
When it is executed without parameters, program works fine. But what if I'd like to pass some extra configuration parameters to my program?
1. c:\> pipetest < file_in > file_out // this works 2. c:\> pipetest /parameter < file_in // also works, writes file_in and parameters to stdout 3. c:\> pipetest /parameter < file_in > file_out // nothing happens !?
Thanks anyone for kind advice and a nice day to all, Y.
// pitest.c #include <stdio.h> #include <fcntl.h> #include <io.h>
int main(int argc,char *argv[]) { int ch,i; for (i = 1; i < argc; i++) { printf("%s\n",a rgv[i]); } setmode(fileno( stdin), O_BINARY); setmode(fileno( stdout), O_BINARY); ch=getc(stdin); while (!feof(stdin)) { putc(ch,stdout) ; } } // -------
Shouldn't the getc() call be inside the while loop?
Of course it should, sorry :( The piece of program I pasted here was
wrong, original of my program is longer and it was not point to bore
anyone with that, when that worked. My loop is working... my only
mistake was I forgot to leave fgetc inside loop - in original it's there
of course... :)
I was confused with the pipes and one guy already found the reply :)
J. 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: Rajarshi Guha |
last post by:
Hi,
I'm having a little trouble when I read from a named pipe. I create a
pipe by
os.mkfifo('/tmp/mypipe')
and then open it for reading with
fin = open('/tmp/mypipe','r+')
|
by: Hoegje |
last post by:
I am writing a C++ program, which should create a sub- process to
start a telnet session to another server. Then it should login to that
server (on the telnet login) and execute one or more command(s) on the
remote server. The C++ program provides all the input for this process
(username, password, servername, commands, ...) and should capture all
the output returned by the telnet session process inside some
variable. How can this be...
|
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 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...
|
by: Greg |
last post by:
I am trying to implement the UNIX pipe command using C but with the
"->" operator. Everything works fine with 1 pipe, but when I try to
use 2 or more, it hangs up when reading the pipe_in filestream. If
ANYONE could offer ANY suggestion as to why this is happening it would
be much appreciated.
Thanks in advance!
| |
by: Steve R. Hastings |
last post by:
While studying iterators and generator expressions, I started wishing I
had some tools for processing the values. I wanted to be able to chain
together a set of functions, sort of like the "pipelines" you can make
with command-line programs.
So, I wrote a module called iterwrap.py. You can download it from here:
http://home.blarg.net/~steveha/iterwrap.tar.gz
|
by: Igna |
last post by:
Hello. I have to write a pipe to joint a GUI in perl and a simulation
program in c. I have read all the docs found in perl.com and now I am
trying to make a test with this simple program if it is working I will
use it for the rest of the prgram. It seems working but it
does not write "bonjour" at the end. Can anybody tell me where my
mistake is? I will be happy for any sample of code for a pipe between c
and perl sent to me too.
Thanks...
|
by: 7stud |
last post by:
Hi,
Can someone explain what a broken pipe is? The following produces a
broken pipe error:
----------
import subprocess as sub
p = sub.Popen(, stdin=sub.PIPE, stdout=sub.PIPE)
|
by: dgk |
last post by:
I trying to use a named pipe but can't figure out how to get the
callback to work:
Module Module1
Private ps As System.IO.Pipes.NamedPipeServerStream
Public Sub main()
Application.EnableVisualStyles()
Try
ps = New System.IO.Pipes.NamedPipeServerStream("Test")
ps.BeginWaitForConnection(AddressOf HandleConnection, "Test")
|
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |