Vely logo Empower C
install     tutorials     examples     documentation     license     about

11.0.11 released on Jul 25, 2022

Command line


Command-line programs

A Vely application can run as a web application or a command line program, or both - such as when some requests can be either fulfilled through web interface or the command line. Note that Vely produces two separate executables: a FastCGI server one and a command line one - they are different because command line interface does not need the FastCGI library and code that uses it, and thus is smaller.

The name of the command-line executable is the same as the application name, and its path is (assuming <app name> is the application name):
/var/lib/vv/bld/<app name>/<app name>


A command line program works the same way as a FastCGI executable, and the output is the same, except that it is directed to stdout (standard output) and stderr (standard error).

Exit code

To specify the exit code of a command line program, use exit-code. To exit the program, use exit-request, or otherwise the program will exit when it reaches the end of a request.

Executing a request

A command line program must obtain its request URL via environment variables, for example if the application name is "stock", here is how to execute it with input-parameter "action" having a value of "show":
export QUERY_STRING="req=stock&action=show"


At the minimum, you must set environment variables REQUEST_METHOD and QUERY_STRING.

Suppressing HTTP header output for the entire application

If you wish to suppress the output of HTTP headers for all requests, set environment variable VV_SILENT_HEADER to "yes" before executing the program:

This will suppress the effect of out-header, or for any other case where headers are output. This has the same effect as silent-header, the only difference is that it applies to the entire application.

URL-encoding the input

QUERY_STRING must be formatted to be a valid URL; for example, data that contains special characters (like "&" or "?") must be URL-encoded, for instance:
export QUERY_STRING="req=stock&action=show&data=a%3Fb"

In this case, field "data" has value of "a?b", where special character "?" is encoded as "%3F".

To make sure all your input parameters are properly URL-encoded, use Vely's v1 code processor:
$($(vv -l)/v1 -urlencode '<your data>')

For instance, to encode "a?=b" as a parameter:
export QUERY_STRING="req=stock&act=show&data=$($(vv -l)/v1 -urlencode 'a?=b')"

POST requests

POST requests must be provided on a standard input, usually by piping the output of another program into your command-line program.


You can also use a command line program with CGI (Common Gateway Interface). Note that CGI programs generaly exhibit much lower performance; use CGI only when warranted by a specific situation.


Running application ( plain_C_FCGI   containerize_application   command_line   application_setup   CGI   FastCGI   FastCGI_client  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. This web page is licensed under CC-BY-SA-4.0.