Difference between revisions of "TProcess"
From Free Pascal wiki
Jump to navigationJump to search (Created page with "'''TProcess''' is an invisible component on the System tab of the Component Palette that enables easy execution of external programs. == Example == See the TProcess e...") |
(from Executing External Programs) |
||
Line 1: | Line 1: | ||
'''TProcess''' is an invisible component on the [[System tab]] of the [[Component Palette]] that enables easy execution of external programs. | '''TProcess''' is an invisible component on the [[System tab]] of the [[Component Palette]] that enables easy execution of external programs. | ||
+ | |||
+ | Some of the benefits of using TProcess are that it is: | ||
+ | * Platform Independent | ||
+ | * Capable of reading from stdout and writing to stdin. | ||
+ | * Possible to wait for a command to finish or let it run while your program moves on. | ||
+ | |||
+ | Important notes: | ||
+ | * TProcess is not a terminal/shell! You cannot directly execute scripts or redirect output using operators like "|", ">", "<", "&" etc. It is possible to obtain the same results with TProcess using pascal, some examples are below.. | ||
+ | * Presumably on Linux/Unix: you '''must''' specify the full path to the executable. For example '/bin/cp' instead of 'cp'. If the program is in the standard PATH then you can use the function [[doc:lcl/fileutil/finddefaultexecutablepath.html|FindDefaultExecutablePath]] from the [[doc:lcl/fileutil/index.html|FileUtil]] unit of the LCL. | ||
+ | * On Windows, if the command is on the path, you don't need to specify the full path. | ||
== Example == | == Example == | ||
− | See the TProcess examples in [[Executing External Programs]]. | + | See the TProcess examples in [[Executing External Programs#TProcess|Executing External Programs]]. |
If there is need for UTF8 string passing, use TProcessUTF8 instead. | If there is need for UTF8 string passing, use TProcessUTF8 instead. | ||
Line 8: | Line 18: | ||
== See also == | == See also == | ||
* [[LCL Unicode Support]] | * [[LCL Unicode Support]] | ||
+ | * [[doc:fcl/process/tprocess.html|TProcess doc]] | ||
{{LCL Components}} | {{LCL Components}} | ||
[[Category:FPC]] | [[Category:FPC]] |
Revision as of 14:53, 17 July 2016
TProcess is an invisible component on the System tab of the Component Palette that enables easy execution of external programs.
Some of the benefits of using TProcess are that it is:
- Platform Independent
- Capable of reading from stdout and writing to stdin.
- Possible to wait for a command to finish or let it run while your program moves on.
Important notes:
- TProcess is not a terminal/shell! You cannot directly execute scripts or redirect output using operators like "|", ">", "<", "&" etc. It is possible to obtain the same results with TProcess using pascal, some examples are below..
- Presumably on Linux/Unix: you must specify the full path to the executable. For example '/bin/cp' instead of 'cp'. If the program is in the standard PATH then you can use the function FindDefaultExecutablePath from the FileUtil unit of the LCL.
- On Windows, if the command is on the path, you don't need to specify the full path.
Example
See the TProcess examples in Executing External Programs.
If there is need for UTF8 string passing, use TProcessUTF8 instead.
See also