Calling external programs

You can call external programs from WarpScript, with the CALL function.

The program must respect some input/output conventions to be called directly within WarpScript. Basically, any program could be executed in a python or shell wrapper you will write.

All your input and output data must be serialized as a one line string, without spaces or new line, using URLENCODE, ->HEX, ->B64, or ->OPB64. In order to pass complex data structure to python easily, Warp 10 also implements ->PICKLE and PICKLE->.

The program launched from CALL will be executed with warp10 user privileges.

Warp 10 configuration

By default, calls directory exists in your Warp 10 home directory.

In your Egress or Standalone configuration, you have to tune or uncomment theses configurations:

warpscript.call.directory = ${standalone.home}/calls
//warpscript.call.maxcapacity =

Python example

(works with Python version up to 3.4)

Your program must be a daemon, waiting for data on the standard input, and pushing back data on the standard output. Your program may be instantiated multiple times by Warp 10. Your program must tell Warp 10 the maximum number of instances that can run in parallel. You can set a hard limit on parallelism with warpscript.call.maxcapacity parameter in Warp 10 configuration.

Your processing may fail. If you want Warp 10 to raise an exception when your program fails, just output a string which begins with a space. If case of program failure, Warp 10 will make another attempt to run your program. If both attempts fail, your WarpScript code will end with an exception.

Make sure that python runs unbuffered, with "-u" flag in the shebang!

Make sure than for one input line, you program will output just one line, even in case of failure. If you output more than one line, one of your script could read the output of the other one.

Python code

#!/usr/bin/python -u
# -*- coding: utf-8 -*-
# This scripts take a list of numbers, and output the square or each number
# If the input list is empty, it fails and output an exception text to Warp 10.
# WARP10 example:
# [ 2 3 4.0 ] ->PICKLE ->HEX 'squareElementsOfAList.py' CALL HEX-> PICKLE->

import pickle
import sys

# Output the maximum number of instances of this 'callable' to spawn

while True:
    # wait for input
    line = sys.stdin.readline()
    # remove leading and trailing spaces, if any
    line = line.strip()
    # rebuild the input list from hex string
    InputArgs = pickle.loads(line.decode("hex"))
    if (len(InputArgs) == 0):
        # starts with a space to raise a Warp 10 exception
        # the utf-8 url encoded string will be displayed in Warp 10 exception
        print(" " + "Empty%20List%20Failure")
        #square inputs
        out_list = [x*x for x in InputArgs]
        # output is pickled and dumped as hex
        output = pickle.dumps(out_list)

Save your file in ./calls/squareElementsOfAList.py, then make it executable chmod +x squareElementsOfAList.py.

Another python example is available here, using base64.

WarpScript code

[ 2 3 4.0 PI SQRT ]
->PICKLE ->HEX 'squareElementsOfAList.py' CALL HEX-> PICKLE->

//test with an empty list
//[ ] ->PICKLE ->HEX 'squareElementsOfAList.py' CALL HEX-> PICKLE->

Bash example

A Bash example is available here, using urlencode.


Your program will be launched and kept alive as long as Warp 10 is alive. If you update your program and try it again from WarpScript, it won't be updated. You must first kill the instances of the program. Restarting Warp 10 is not needed.

You can remove the main loop and exit after the output is printed. If you do so:

  • Performance of multiple calls in a WarpScript will be degraded.
  • The exception raised by a space at the beginning of output will not be handled correctly, because Warp 10 will try again to get a result. Your WarpScript will end with "CALL subprogram died unexpectedly".

Calling Web Services

Warp 10 allow you to make outbound GET or POST HTTP call with WEBCALL function.

Request is sent asynchronously from WarpScript execution, you cannot retrieve the result of the request.

The purpose is to trigger webhooks in your WarpScripts, or to push data to other services easily.


In your configuration, you may have to tune theses configurations:

  • warpscript.maxwebcalls = 4
  • webcall.user.agent = Warp10-WebCall
  • webcall.host.patterns = .*


See WEBCALL documentation.