Xref: utzoo comp.unix.questions:6802 comp.lang.c:9817 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: Command line as a stream? Message-ID: <20376@think.UUCP> Date: 1 May 88 00:34:49 GMT References: <404@lscvax.UUCP> Sender: usenet@think.UUCP Reply-To: barmar@fafnir.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 26 Keywords: C, command line In article <404@lscvax.UUCP> ram@lscvax.UUCP (Ric Messier) writes: >Since I know input gets buffered, I am assuming that that buffer can be >opened by specifying it in a stream. Am I wrong in this assumption? Any >help would be greatly appreciated!! Thanks! First of all, you can't be sure that your command was actually called by the shell. It might have been invoked by a program calling system() or exec(). When it is called from the shell, the command line is buffered, but unfortunately it is not anywhere accessible to the program. It is buffered in the shell's process, but the command is run in a separate process. The best thing for you to do would be to have a pair of global variables, global_argc and global_argv, and have main() do global_argc = argc; global_argv = argv; Then you can refer to these from anywhere in your program. Barry Margolin Thinking Machines Corp. barmar@think.com uunet!think!barmar