# 🛠 Script Syntax and Parameter Substitution When defining a CCP method, you provide two shell-based scripts: - **`deploy-script`**: sets up the environment (e.g. installs dependencies, downloads files) - **`execute-script`**: runs your algorithm using the inputs provided These scripts support dynamic variable injection and conditional logic. --- ## 📌 Placeholder Syntax: `{{parameter_id}}` Any input parameter defined in your `method.json` can be referenced in scripts using double curly braces. ```bash echo "The input URL is {{file_url}}" ``` At runtime, CCP will substitute `{{file_url}}` with the actual value passed by the user. --- ## 📥 Downloading Files with `curl` Use `curl` to download files passed as remote URLs: ```bash curl -L {{file_url}} -o /ccp_data/input.txt ``` Notes: - `-L` follows redirects (important for Google Drive, Dropbox, etc.) - Save everything in `/ccp_data/` to make outputs accessible --- ## ⚠️ Optional Parameters Use shell logic to **check if a parameter has been set** before using it: ```bash [ -n "{{optional_param}}" ] && echo "Optional param was provided" ``` ### Example ```bash [ -n "{{mask_url}}" ] && curl -L {{mask_url}} -o /ccp_data/mask.png ``` This prevents the script from failing when the user leaves a field empty. --- ## 🔁 Building Dynamic Commands For complex CLI tools, build your command step-by-step: ```bash cmd="wordcloud_cli --text /ccp_data/input.txt" cmd="$cmd --width {{width}} --height {{height}}" [ -n "{{max_words}}" ] && cmd="$cmd --max_words {{max_words}}" eval $cmd ``` This allows you to include optional flags only when they are present. --- ## 📦 Output Location Always write result files to `/ccp_data/`, like: ```bash python tool.py --output /ccp_data/results.csv ``` CCP will include these in the downloadable archive and display them in the UI. --- ## ✅ Quick Reference | Task | Example | |-----------------------|----------------------------------------------| | Inject parameter | `{{input}}` | | Required download | `curl -L {{url}} -o /ccp_data/file.txt` | | Optional download | `[ -n "{{url}}" ] && curl ...` | | Dynamic command | `cmd="..."; eval $cmd` | | Output file | Write to `/ccp_data/` | ## 🔗 Related Pages - 🔣 [Defining method.json](./07_method_json.md) - 🐧 [Docker runtime (ccpimage)](./02_defining_ccpimage.md) - 🐍 [Python-based methods](./03_python_method.md) - 🔧 [Workflow overview](./01_method_development_flow.md)