Command Line Tools

From Lianjapedia
Jump to: navigation, search

Overview

Lianja Command Line Tools are run at the Operation System prompt from a Windows command window or Linux / macOS terminal window.

See Also

Background Tasks, Command Line Switches, COMPILE, Lianja Package Manager, Lianja Server Manager on Linux, Lianja Server Manager on Mac, License Management on Linux, License Management on Mac, Script Editor

lianja <.lpk>

Install a Lianja package file and open it in the Lianja App Builder.

lianja <.lpk filename>

Passing the name of a package file to the lianja command allows the package to be installed and opened in the Lianja App Builder.

It assumes that an App with the same name as the package is included in the package.

If it has already been installed and the version is the same then the App will be opened without being updated.

  • Windows
start /wait lianja c:\lianja\packages\doc_alias-1.0.lpk
  • Linux
lianja doc_alias-1.0.lpk
  • macOS
lianja doc_alias-1.0.lpk

The files from the package are listed in the terminal/command window as they are installed (Windows only).

If the package version of the App is already installed, a 'Package is already installed' message is displayed in the window.

The App is then opened in the Lianja App Builder.

lianja-lm

The lianja-lm License Management utility can be used to activate, deactivate and validate Lianja licenses on Linux and macOS.

Lianja App Builder Licenses

lianja-lm --activate [LianjaAppBuilder] <productkey>
    | --deactivate [LianjaAppBuilder]
    | --validate [LianjaAppBuilder] 

This command should be run as root / using sudo.

Option Description
--activate [LianjaAppBuilder] <productkey> Activate the specified license <productkey>
--deactivate [LianjaAppBuilder] Deactivate the current license
--validate [LianjaAppBuilder] Validate the current license. This checks if the current license is valid.

Lianja Server Licenses

For Lianja Cloud Server and Lianja SQL Server.

lianja-lm  --activate LianjaServer <productkey>
    | --deactivate LianjaServer
    | --validate LianjaServer

This command should be run as root / using sudo.

Option Description
--activate LianjaServer <productkey> Activate the specified license <productkey>
--deactivate LianjaServer Deactivate the current license
--validate LianjaServer Validate the current license. This checks if the current license is valid.

lianja-lpk

Handle Lianja package files.

List

lianja-lpk list <.lpk filename>

Build

Use special prefixes such as 'app:/' and 'lib:/' for the files. Separate filelist files with ; on Windows and + on Linux/macOS.

lianja-lpk build <.lpk filename> file | filelist

Add

Use special prefixes such as 'app:/' and 'lib:/' for the files. Separate filelist files with ; on Windows and + on Linux/macOS.

lianja-lpk add <.lpk filename> file | filelist

Refresh

lianja-lpk refresh <.lpk filename>

Install

lianja-lpk install <.lpk filename> [<lOverwrite>]

By default the package file will be installed whether the App is already installed or not. If <lOverwrite> is false or .F., then existing App files will not be overwritten.

Update

lianja-lpk update <.lpk filename> [<lOverwrite>]

If <lOverwrite> is false or .F., then existing App files will not be overwritten, otherwise they will be overwritten.

Deploy

lianja-lpk deploy <.lpk filename> <url[:8001]>,<apikey>[,<uid>,<pwd>]

Deploy to the Lianja Cloud Server at the specified <url>. This can be directly to the Lianja Cloud Server by specifying the port  :8001 on the http URL, or via IIS on Windows or Apache on Linux (http or https).

The optional <uid> and <pwd> are the username and password for a valid user on the server with admin permissions.

The <uid> and <pwd> can be omitted:

  1. If the 'admin' user on the server has the default 'admin' password, these will be used. Note: for security reasons, the password for the 'admin' user should be changed from the default on deployed systems.
  2. If the following environment variables are set on the deploying system and contain respectively the username and password for a valid user on the server with admin permissions, these will be used.
  • LIANJA_LPKUID
  • LIANJA_LPKPWD

Examples

  • Windows
lianja-lpk list c:\lianja\packages\doc_alias-1.0.lpk
lianja-lpk build webapp1-1.0.lpk app:/example_webapp1
lianja-lpk build webapp123-1.0.lpk ^
app:/example_webapp1;app:/example_webapp2;app:/example_webapp3;lib:/helloworld.prg
lianja-lpk add webapp1-1.0.lpk ^
app:/example_webapp1;app:/example_webapp2;app:/example_webapp3;lib:/helloworld.prg
lianja-lpk refresh c:\lianja\packages\doc_alias-1.0.lpk
lianja-lpk install c:\lianja\packages\doc_alias-1.0.lpk
lianja-lpk install c:\lianja\packages\doc_alias-1.0.lpk false
lianja-lpk update c:\lianja\packages\doc_alias-1.0.lpk
lianja-lpk update c:\lianja\packages\doc_alias-1.0.lpk false
lianja-lpk deploy doc_alias-1.0.lpk ^
http://win2012.lianja.local:8001,7c52c139-b88d-4756-8695-93a76264e53f
lianja-lpk deploy doc_alias-1.0.lpk ^
http://win2012.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f,admin,1$%p4ss
lianja-lpk deploy doc_alias-1.0.lpk ^
http://win2012.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f,super1,2$%p4ss
set LIANJA_LPKUID=super1
set LIANJA_LPKPWD=2$%p4ss
lianja-lpk deploy doc_alias-1.0.lpk ^
http://win2012.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f
  • Linux
lianja-lpk list doc_alias-1.0.lpk
lianja-lpk build webapp1-1.0.lpk app:/example_webapp1
lianja-lpk build webapp123-1.0.lpk \
app:/example_webapp1+app:/example_webapp2+app:/example_webapp3+lib:/helloworld.prg
lianja-lpk add webapp1-1.0.lpk \
app:/example_webapp1+app:/example_webapp2+app:/example_webapp3+lib:/helloworld.prg
lianja-lpk refresh doc_alias-1.0.lpk
lianja-lpk install doc_alias-1.0.lpk
lianja-lpk install doc_alias-1.0.lpk false
lianja-lpk update doc_alias-1.0.lpk
lianja-lpk update doc_alias-1.0.lpk false
lianja-lpk deploy doc_alias-1.0.lpk \
http://ubuntu20.lianja.local:8001,7c52c139-b88d-4756-8695-93a76264e53f
lianja-lpk deploy doc_alias-1.0.lpk \
http://ubuntu20.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f,admin,1$%p4ss
lianja-lpk deploy doc_alias-1.0.lpk \
http://ubuntu20.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f,super1,2$%p4ss
LIANJA_LPKUID=super1; export LIANJA_LPKUID
LIANJA_LPKPWD=2$%p4ss; export LIANJA_LPKPWD
lianja-lpk deploy doc_alias-1.0.lpk \
http://ubuntu20.lianja.local,7c52c139-b88d-4756-8695-93a76264e53f
  • macOS
lianja-lpk list doc_alias-1.0.lpk
lianja-lpk build webapp1-1.0.lpk app:/example_webapp1
lianja-lpk build webapp123-1.0.lpk \
app:/example_webapp1+app:/example_webapp2+app:/example_webapp3+lib:/helloworld.prg
lianja-lpk add webapp1-1.0.lpk \
app:/example_webapp1+app:/example_webapp2+app:/example_webapp3+lib:/helloworld.prg
lianja-lpk refresh doc_alias-1.0.lpk
lianja-lpk install doc_alias-1.0.lpk
lianja-lpk install doc_alias-1.0.lpk false
lianja-lpk update doc_alias-1.0.lpk
lianja-lpk update doc_alias-1.0.lpk false

lianja-comp

Compile one or more Lianja/VFP prg files. A fully licensed Lianja App Builder must be installed.

lianja-comp <filename.prg> | <skeleton> | <@textfile>
  • Windows
cd c:\lianja\cloudserver\tenants\public\library
lianja-comp chartlib.prg
lianja-comp *.prg
dir /B *.prg > prgs.txt
lianja-comp @prgs.txt
  • Linux
cd /opt/lianja/cloudserver/tenants/public/library
lianja-comp chartlib.prg
lianja-comp *.prg
ls *.prg > prgs.txt
lianja-comp @prgs.txt
  • macOS
cd /Users/Shared/Lianja/cloudserver/tenants/public/library
lianja-comp chartlib.prg
lianja-comp *.prg
ls *.prg > prgs.txt
lianja-comp @prgs.txt

lianjarun

Run a background script or command. Available with the Lianja App Builder and Lianja Cloud Server installations.

lianjarun [--runtime] --input | -i <script> --output | -o <output file>
lianjarun [--runtime] --command | -c <command> [--output | -o <output file>]

--input and --output

You specify the input file using the -i (--input) command line switch and the output file using the -o (--output) command line switch.

You can, for example, generate an HTML report and email that to someone using the Amazon AWS Simple Email Service if you have an AWS account.

Examples:

Run a Lianja/VFP script in the current directory.

lianjarun -i myscript.dbo -o myreport.html

Run a python script in the lianjademo app.

lianjarun -i app:/lianjademo/lianjademo_pythondb.py -o myreport.html

Run a PHP script in the lianjademo app.

lianjarun -i app:/lianjademo/lianjademo_phpdb.php -o myreport.html

Run a JavaScript script in the lianjademo app.

lianjarun -i app:/lianjademo/lianjademo_javascriptdb.js -o myreport.html

Notice that these examples will access the development directories as they run lianjarun. If you want to access the runtime directories use the lianjarun command with the --runtime command line switch as shown below.

You can find a full list of command line switches here.

You can perform database admin tasks from the console or in background scripts.

--command

The -c (--command) command line switch allows multiple commands to be concatenated into a script. Each line should be separated with a semi colon and no block statements are supported e.g if, for, do while etc.

lianjarun -c "open database southwind;select top 5 customerid,contactname,companyname \
from customers"
 CUSTOMERID CONTACTNAME                    COMPANYNAME                             
 ALFKI      Maria Anders                   Alfreds Futterkiste
 ANATR      Ana Trujillo                   Ana Trujillo Emparedado
 AROUT      Thomas Hardy                   Around the Horn again
 BERGS      Christina Berglund             Berglunds snabbkop
 BLAUS      Hannah Moos                    Bill's furniture store
5 records selected in <1ms
lianja -c "backup database southwind;"
lianja -c "optimize database southwind;"

If required you can redirect output using the -o switch.

lianjarun -c "open database southwind;select top 5 customerid,contactname,companyname \
from customers" -o mydata.txt

--runtime

If --runtime is specified, the commands operate against the runtime/deployed data and files, otherwise they operate within the context of the App Builder.

lianjarun --runtime -c "select top 5 customerid,contactname,companyname \
from southwind!customers"
lianjarun --runtime -i lib:/myscript.dbo -o myoutput.txt