Blogpost

1 minute read

Use your preferred language to create tasks

Use your own preferred programming language to create platform tasks. If it is PHP, Python, Ruby, ... we got you covered.

Our cloud platform allows you to define any type of task that you want to run in a scenario.

Usually these tasks are bash related instructions. For example: apt-get install, mkdir, …

Not everybody is comfortable with writing bash scripts, especially when some logic or complex conditions are necessary.

To handle this, the platform supports the usage of the typical programming & scripting languages. Ranging from Python to PHP to NodeJS to Ruby. Any scripting language that does not require any compiling is available for you to use.

To use any of these languages in a “Task”, you only have to change the first line in the “task”.

An example to get you started:

Usually this would be #!/bin/bash but by changing this to #!/usr/bin/env php, the task will use the PHP binary. This “line” is referred to in the Unix worlds as “shebang”.

Example of a task to read a file:

#!/usr/bin/env php

<?php

$my_file = '/opt/approot/file.txt';

// your logic....

By using the appropriate “shebang” the platform will try to execute using the binary indicated.

Other typical “shebang” options are:

  • #!/usr/bin/env php – Execute task using PHP
  • #!/usr/bin/env python – Execute task using Python
  • #!/usr/bin/env node – Execute task using NodeJS
  • #!/usr/bin/perl -T – Execute tasks using Perl with the option for taint checks
  • #!/usr/bin/env ruby -w – Execute task using Ruby with warnings

Want to find out what we can do for you?