<doc>
	<legacy_id>2442</legacy_id>
	<name>open process</name>
	<type>command</type>

	<syntax>
		<example>open [elevated] process <i>appName</i> [for [[<i>encoding</i>] text | binary] {read | write | update | neither}]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Starts a program.</summary>

	<examples>
<example>open process "/usr/bin/snapfile"</example>
<example>open process it for read</example>
<example><p>command startSlave pProcess</p><p>   open process pProcess for text update</p><p>   send "monitorSlave pProcess" to me in 50 millisecs</p><p>end startSlave</p></example>
	</examples>

	<history>
		<introduced version="1.0">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		<changed version="7.0">Added encoding support</changed>
<changed version="4.5">Added elevated keyword</changed>
<changed version="4.5">Added extra example.</changed>
<changed version="2.0">2.0</changed>
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
	</platforms>

	<classes>
		<desktop/>
		<web/>
	</classes>

	<security>
		<process/>
	</security>


	<classification>
		<category>The System Environment</category>
	</classification>

	<references>
		<function tag="screenName">screenName Function</function>
		<command tag="kill">kill Command</command>
		<command tag="read from process">read from process Command</command>
		<property tag="hideConsoleWindows">hideConsoleWindows Property</property>
	</references>

	<description>
	<overview>Use the <b>open process</b> <glossary tag="command">command</glossary> to start up a <glossary tag="process">process</glossary> you want to either send data to or get data from or both.</overview>

		<parameters>
  <parameter>
    <name>appName</name>
    <description>Is the location and name of the program you want to open. You can run only one instantiation of a given program at one time. The appName can be any program on the system.</description>
  </parameter>		</parameters>

	<value></value>
	<comments>Usually, you should use the <b>open process</b> <glossary tag="command">command</glossary> only to start up programs that run in the <object tag="group">background</object>, without any user interaction. When you are finished with the <glossary tag="process">process</glossary>, use the <command tag="close process">close process</command> <glossary tag="command">command</glossary> to cause it to <control_st tag="exit">exit</control_st>.<p></p><p>You can optionally specify either text or binary mode. If you specify text mode, when you use the <b>write to process</b> <glossary tag="command">command</glossary>, any line feed and return <keyword tag="characters">characters</keyword> are translated to the appropriate end-of-line marker for the current operating system before being written to the process. (The end-of-line marker on <glossary tag="Mac OS">Mac OS</glossary> and <glossary tag="OS X">OS X systems</glossary> is a return character; on <glossary tag="Unix">Unix</glossary>, a line feed; on <function tag="openStacks">Windows</function>, a CRLF.) If you specify binary mode, return and line feed characters are not translated. If you don't specify a mode, the process is opened in text mode.</p><p></p><p>Use the read form to open the process for reading. If the process is opened for reading, you can use the <b>read from process</b> <glossary tag="command">command</glossary> to examine its output, but you can't send data to it.</p><p></p><p>Use the write form to open the process for writing. If the process is opened for writing, you can use the <b>write to process</b> <glossary tag="command">command</glossary> to send input data to it.</p><p></p><p>Use the update form to open the file for both reading and writing. If the file is opened for update, you can use both the <b>read from process</b> and <command tag="write to process">write to process</command> <glossary tag="command">commands</glossary> to send input to it or get output from it.</p><p></p><p>Use the neither form to run the process without reading data from it or sending data to it. (Using this form is equivalent to using the <b>launch</b> <glossary tag="command">command</glossary> to start up a program.) <glossary tag="process">Processes</glossary> opened with the neither form will quit automatically when finished running.</p><p></p><p>When you quit the application, processes opened with the read, write, or update forms are quit automatically.</p><p></p><p></p><p></p><p></p><note>On OS X systems, you can use the <b>open process</b> command to start up an application, but not a Unix process. To work with a Unix process, use the shell func instead.</note><p></p><p></p><p></p><p></p><change>In versions before 1.1.1, when you quit the application, any processes that had been opened with the neither form were quit automatically on Windows systems.<p></change><p>Support for using the <b>open process</b> <glossary tag="command">command</glossary> on <glossary tag="OS X">OS X systems</glossary> was added in version 2.0.</p><p></p><p></p><p></p><p></p><p></p><change>Sometimes it is necessary to perform operations on the local machine as an administrator, and a typical pattern for a GUI application doing this is for it to prompt for authentication at certain points.<p></change><p>Modern operating systems do not permit a process to elevate itself, nor grant itself increased privilege. Instead, they only allow a running process to launch another process with increased privilege. Therefore, in order to support this, in version 4.5 a new form of the open process command was introduced that can launch a slave process with elevated permissions:</p><p></p><p>&#9;open elevated process process [ for [ text | binary ] ( read | write | update | neither ) ]</p><p></p><p>This form operates identically to the normal version, except that engine will ask the system to launch the given process with admin/root privileges.</p><p></p><p>The standard way for a GUI application that needs to perform privileged operations to be structured is to split the application into two parts: a GUI front-end that interacts with the user, and a command-line back-end that is run with elevated permissions. These two parts can then talk to each other using a standard master-slave approach, or some other form of IPC such as sockets</p><p>&#9;</p><p></p><p></p><p></p><change></change>The possibility of choosing an encoding when opening a process for a text operation was added in 7.0. It follows the encodings available in the functions <function tag="textEncode">textEncode</function> and <function tag="textDecode">textDecode</function>. &#9; &#9;</comments>
	</description>
</doc>