You can use the Mac OS Terminal or the Windows console to drive your 4D applications (4D and 4D Server) using command lines. More particularly, this functionality allows you to open a database remotely, which can be especially useful for administering Web servers.
You can execute commands lines for 4D applications using the Mac OS X Terminal or the Windows console.
- Under OS X, you should use the open command.
- Under Windows, you can just pass the arguments directly.
Note: Under OS X, you can pass the arguments directly by going to the folder where the application is found inside the package (Contents/MacOS path). For example, if the 4D package is located in the MyFolder folder, you must write the command line as follows: /MyFolder/4D.app/Contents/MacOS/4D &. However, we recommend that you use the open command.
Here is a description of command lines and their arguments which are supported by 4D applications. These examples assume that your 4D application is stored on the desktop and that the database to be opened is found in the "Documents" folder.
Note: The current folder of the user is reached using the "~ " command under OS X and the "%HOMEPATH%" command under Windows.
- Launch application with a structure file and a data file
Syntax: applicationPath --structure structurePath | packagePath --data dataPath
OS X Example:
open ~/Desktop/4D.app --args --structure ~/Documents/myBase.4dbase --data ~/Documents/data/myData.4DD
Windows Example:
%HOMEPATH%\Desktop\4D\4D.exe --structure %HOMEPATH%\Documents\myBase.4dbase\myDB.4db --data %HOMEPATH%\Documents\data\myData.4DD
or:
%HOMEPATH%\Desktop\4D\4D.exe /structure %HOMEPATH%\Documents\myBase.4dbase\myDB.4db /data %HOMEPATH%\Documents\data\myData.4DD
This command launches the application and opens the designated structure file with the selected data file. No dialog box appears.
- Quit application (OS X only)
Syntax: kill -s INT process_ID
Example:
kill -s INT 323
The action of this command is identical to selecting the Quit command. The processes are shut down one by one; the cache is saved; and the application quits.
Note: The process number of the 4D application (process_ID) can be obtained using commands such as ps or top.