[fpc-pascal] It is possible to pass command line to pascal
wkitty42 at windstream.net
Sun Jun 30 14:56:33 CEST 2013
On 6/30/2013 08:44, Rainer Stratmann wrote:
> On Sunday 30 June 2013 14:14:56 you wrote:
>> In which case why is he putting ls in front of it?
> I guess he simply does not know by now and tries out something.
don't guess... others cannot learn from assumptions and guesses...
>> -r is a valid option
>> to both uname and ls, so since we're already looking at a broken command
>> it's entirely valid to ask which it's supposed to apply to.
> I bet he wants to know the Linux version.
> 'uname -r' is the unambiguous assignment for that.
while that is true, there is still the ambiguous 'ls' in front which will return
an error of "file not found" and an exit code of 1...
>>> With 'uname -r> file.txt' you redirect the output in a file.
>>> Then cou can read the file.
>>> I am sorry, but you try to make a very simple thing complicated.
>> You might call having to invoke a shell with the -c option to get the
>> redirection working, working out where to put the temporary file,
>> deleting it on completion and making sure that all error conditions are
>> handled "simple". I certainly don't.
> It is not necessary to delete the file.
so you propose to leave temporary files laying about all over the place
polluting the filesystem?
> All error conditions you can read in the man page of the command.
only if man is installed and if the manpages for that command exist... this
cannot be assumed to be true all the time and for all situations...
>> But as Marco has already reminded us, the information is already
>> available from a standard library call.
> Very good! Then you bet, too?
only IF that is the information the OP is looking for... we don't know yet what
that information is because the leading 'ls' has not been addressed...
>> Calling an external program is
>> not something to be approached for a trivial reason,
> It works perfectly with linux. And is simple. The command is executed like
> every other function in your pascal program.
but capturing the output is not simple... redirection is a function of the shell
and your example doesn't load the shell to start with...
>> unless you're
>> writing shell or in a scripting language such as Perl where it might be
>> less trouble than searching CPAN for the appropriate extension module.
> Why do you try to make it magotty and more complicated than necessary?
make it what?? you cannot redirect without the shell or by taking additional
steps to emulate what the shell does to allow redirecting...
NOTE: No off-list assistance is given without prior approval.
Please keep mailing list traffic on the list unless
private contact is specifically requested and granted.
More information about the fpc-pascal