[fpc-pascal] It is possible to pass command line to pascal

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun Jun 30 12:32:30 CEST 2013

Rainer Stratmann wrote:
>  On Sunday 30 June 2013 00:59:59 you wrote:
>> I Tried, but only return an integer not a string value.
> Thats right.
> You have to put the result in a file and then afterwards read the file.
> ls uname -r > file.txt

I'm sorry, but that's misleading on at least two accounts. The first is 
that redirection (> and so on) is a property of the shell, so it won't 
work unless you pass the entire command to a shell with (typically) the 
-c option. The second is that as linked by leledumbo earlier 
http://wiki.lazarus.freepascal.org/Executing_External_Programs there are 
specific facilities in the runtimes to do this sort of thing and they 
don't, as a rule, involve temporary files.

If I had to go on, what's that -r supposed to be doing? Are you trying 
to execute  uname -r  and in that case where does the  ls  come into it? 
Perhaps what you're really trying to do is something like

ls /boot/vmlinux-`uname -r`

(note those backticks which are NOT standard quotes) in which case you'd 
be better first getting the  uname  output and then using standard file 
operations to get the properties you're interested in. Finally, Linux 
(but not necessarily other unix implementations) puts version 
information into /proc/version which is accessible as a standard file- 
no external program required.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list