Newbie question
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Newbie question




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Newbie question  
K.M Jr


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-29-04 08:09 AM

Hi group,

I got a pretty simple question -

Say I have a C program (executable as a.out)
What does this do - a.out < foo.txt

I believe I am piping foo.txt to a.out. But how is it available to
program i.e.  how do I access foo.txt in the program ?

How is it different from  - a.out  foo.txt

Thanks.





[ Post a follow-up to this message ]



    Re: Newbie question  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-29-04 08:09 AM

In article <8228b1d2.0409290041.3a4b88c6@posting.google.com>,
opwv_pspl_test2@yahoo.com (K.M Jr) wrote:

> Hi group,
>
> I got a pretty simple question -
>
> Say I have a C program (executable as a.out)
> What does this do - a.out < foo.txt
>
> I believe I am piping foo.txt to a.out. But how is it available to
> program i.e.  how do I access foo.txt in the program ?

No, there's no pipe -- a pipe is a connection between two processes.
The shell opens foo.txt and connects it to the process's standard input.
You access it by reading from stdin.

>
> How is it different from  - a.out  foo.txt

In this case, the program has to open the file itself.

By convention, most Unix programs that accept filename arguments will
automatically read from standard input if they don't get any filenames.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***





[ Post a follow-up to this message ]



    Re: Newbie question  
Nils O. Selåsdal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-30-04 01:09 AM

K.M Jr wrote:
> Hi group,
>
> I got a pretty simple question -
>
> Say I have a C program (executable as a.out)
> What does this do - a.out < foo.txt
The shell opens foo.txt as stdin for you.

> I believe I am piping foo.txt to a.out. But how is it available to
> program i.e.  how do I access foo.txt in the program ?
>
> How is it different from  - a.out  foo.txt
The string foo.txt will be in argv[1], and you have to
open it if desired.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:35 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register