/

Run a Bash Script (Advanced)

Learn how to automate a job run by using a bash script.


Introduction

After you explored the API, created a workflow and ran a job, you can automate the individual API commands by using a bash script. The following script uses only the project credentials (project ID and project API key) as input variables.

This bash script will use the previously created workflow and run another job based on the input parameters defined in this script. For more information about the blocks added to the workflow, please refer to Add Blocks to a Workflow (API).

Download the Script

  1. Clone this script to your local machine:
git clone https://gist.github.com/cb241bbd104aab30274d80ced9e4b313.git up42-first-api-script
  1. Go to the script directory and make the file executable:
cd up42-first-api-script
chmod 755 first_job_run.sh

Run the Script

  1. Locate your project credentials (project ID and project API key). For more information, please refer to Authentication.
  2. Run the script by providing the project API key and project ID as variables:
 ./first_job_run.sh -k <project API key> -p <project ID>

Example:

 ./first_job_run.sh -k pRj1h8Nv.Mmguja9BsLJXPWlvWt3h9vwAIftlcSHQSj1 \
 -p 1ae70a40-07e9-47a7-9c25-bea19af1c451
  1. The response will display information about the job ID and job status:
Job ba95835a-a82b-436d-841a-f4141139a738 is NOT_STARTED

If you invoke the script more times, more jobs will be launched, each with a unique job ID. This will also trigger a larger credit consumption.