Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Let's assume that there are no command-line arguments. How do you pass input data to a program?

I'm thinking you'd write the input to a file with a specific name, such that the program knows to open and read it as input. However, how would one discover the name of that file? Usually, running a command-line program without arguments or with some standard help argument (e.g. \?) produces some instruction on how to use it. But given an environment with no command-line arguments, how does one discover how to operate a program?

share|improve this question
Not programmers related. Not sure this is even a stackoverflow question. Most probably a better fit for –  karlphillip Mar 19 '12 at 13:20
Stackoverflow FAQ said "Professional programmers interested in conceptual questions about software development, ask on Programmers.". Isn't this a conceptual question about software development? –  Core Xii Mar 19 '12 at 13:24
@karlphillip - there's no code. It's a design question. –  ChrisF Mar 19 '12 at 13:29
@karlphillip: It is certainly not a reverse engineering question. It's about operating system design, actually. –  Core Xii Mar 19 '12 at 13:38
Do you need to understand how an existing program is doing this? Do you need to do something like that and you want to get some tips? –  Adriano Repetti Mar 19 '12 at 13:42

9 Answers 9

You can use tools to display all the hardcoded strings inside the application, and hopefully the filename will show up.

Check OllyDBG on Windows and strings on Linux (it's a cmd-line application).

A more complex solution: fire up your favorite asm debugger (OllyDBG, GDB) and get your hands dirty.

share|improve this answer
Ah yes, one could read the program file and it could contain a standard header with this information. Though that somewhat postpones the issue - somehow you must then discover that standard. –  Core Xii Mar 19 '12 at 13:27
The idea is to dump all the strings in the program. This can display a lot of interesting information, and one of those could be name of the file he is looking for. –  karlphillip Mar 19 '12 at 13:29

In the .NET world, this is achieved with the use of an app.config file included with your source code. This is copied to the output folder with a name following the convention "MyApp.exe.config" where your application is "MyApp.exe".

I don't know if there are similar conventions for other languages.

share|improve this answer
A standardized, human-readable, self-documenting file describing the program's operation, supplied with it. Also known as a manual. Funny that didn't occur to me. –  Core Xii Mar 19 '12 at 13:43
I'm not sure what you're saying. I've not described the manual in the answer. –  RichardM Mar 19 '12 at 14:10
Well, that's the idea you gave me anyway. What I got from your answer was that there's some other, standardized file supplied with the program that hints to its operation one way or another. –  Core Xii Mar 19 '12 at 14:22
The app.config file contains the application settings that are your inputs. Here's a link with more details and samples:… –  RichardM Mar 19 '12 at 14:45

Popular convention seems to be for programs to use standard streams for stuff like that:

In computer programming, standard streams are preconnected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution...

You can see how it works using whatever command interpreter is available in your OS. In Windows, you may launch DOS shell and type help. In Unix you launch shell and type man.

share|improve this answer
Yes indeed. Though, without command-line arguments, there are no pipes, and as such, standard I/O would likely not be present as it'd be somewhat useless. –  Core Xii Mar 19 '12 at 13:49
@CoreXii you may want to clarify your question pointing out that no standard I/O is expected to be used, either –  gnat Mar 19 '12 at 13:54
It's not that it isn't expected. If it's the best solution, it's certainly valid. But given that pipes don't exist, I'd explore others first. –  Core Xii Mar 19 '12 at 13:58
@Core Xii: Mistaken assumption. There is no reason to presume that pipes exist only in the presence of command lines. Win32 on Win95 is an obvious counter-example. It did have pipes, but not CMD.EXE (the 32 bits command line). –  MSalters Mar 19 '12 at 15:01

You could look at COM, as implemented by Microsoft. In that system, the OS loads your DLL into memory when someone needs an object of your type. If anyone needs to pass information to that object, it can use the standard IUnknown::QueryInterface(GUID) method to obtain an well-known interface, and then pass information via that interface.

Of course, if your object doesn't have such an interface, it'd return E_NO_INTERFACE. But that's no different (just eassier to debug) than a CLI program ignoring its arguments.

share|improve this answer

Many Operating Systems already have the concept of "environment variables". This is a set of named values that are passed to every process, in addition to the command line arguments. Using C, you'd access them with getenv().

Similar to the /? convention for command lines, the OS writer can define a convention that the presence of a HELP variable in the environment means that a program should show usage information. In C code: if (getenv("HELP")) { ShowHelp(); }

share|improve this answer

I don't quite understand what the OP is really asking, but it is fairly common for command line programs to use environmental variables as inputs in lieu of command line parameters.

Of course that begs the question of where did the environmental variables come from.

share|improve this answer

If you have to instruct an application about its job without parameters I think you can call that...configuration in the more old meaning of the term. Depending on the environment (Windows or Linux?) and the language/framework (Java? Any .NET language?) your choice will be really different. You speak about

an environment with no command-line arguments

so I guess you do not have a console application. Moreover I guess (again) that your application when launched will do its job and then terminate. So your question is "how users may change application options?".

You can use a configuration file, what - in this case a more advanced - user will expect depends on the environment. I don't think it's a good solution for end-users or non technical personnel. They have to know or to guess that in the application directory (or in the user home directory or something like that) there is a configuration file of some sort.

You can provide some kind of help (man page, plain text file, HTML help or HTML file) to teach your user what to search and where. I think you should always do this but sometimes technical details aren't clear for every user and you give them a chance to break your application in many many ways because a wrong configuration (they may save your configuration file with the wrong encoding, break its syntax, write something stupid).

Finally the solution I prefer: you may provide two applications, one to do the job and another one for configuration purposes. Configuration is still saved somewhere (so advanced users may enjoy more advanced esoteric options) and normal users will have a user-friendly interface (like xconfig, for example).

The format used to store these data is up to you. Usually I think to be coherent with the environment is the most important thing but how your application will be used is also important: you may use the Registry (in Windows), XML configuration files, JSON configuration files, INI-like configuration files. It depends on the kind of data you need to store. Sometimes a simple text file for command line arguments used as response file is enough.


If your application may have multiple configurations and multiple instances you need to make the configuration file runnable. How is environment dependant. In Windows, for example, you may register a ".MyApplication.config" file extension. Users won't run (with double click...) the application itself but the configuration file, application will be run by OS with the configuration as parameter.
Configuration will be a document and user will see that document, not the application (moreover you may provide extra verbs for editing).

share|improve this answer
It's not about configuration but input. While one might argue that the input to a program is a manner of configuration of its operation, the main point here is that each invocation of the program calls for different input, and several instances of the program may be running at once. Therefore it's not feasible to direct the program to the desired input from a single configuration file (as it would have to be opened exclusively by each party). Your assumption that the program does its job and terminates is correct. –  Core Xii Mar 19 '12 at 14:16
Updated the answer –  Adriano Repetti Mar 19 '12 at 14:24

You can create .bat file with your arguments in it.

share|improve this answer

I'm going for a straight-man answer.

You read the user's manual. Then you use some sort of input device like a keyboard or mouse to control the program. If the program requires a large amount of data, you can direct it to a file. Directing a program to a file has varied widely through the ages, but has standardized to OS typical popup windows.

If it's a command line program, with no command line arguments, then you are dependent on the program's interface. At some point you probably have to type in the path to the file name.

share|improve this answer
And how would you use such a program from another program? It must be usable without user intervention. –  Core Xii Mar 19 '12 at 22:18
@CoreXii, That'd be a great detail to add to the question. –  Philip Mar 20 '12 at 14:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.