簡體   English   中英

databricks-cli:在bash腳本中運行作業時JSONDecodeError

[英]databricks-cli: JSONDecodeError when running job in bash script

我正在嘗試在Linux服務器上的bash腳本中使用筆記本參數運行Databricks作業。 我正在按照文檔中的說明進行操作,並且已經驗證了命令可以在終端中使用。

這是我的腳本:

#!/bin/bash

### this commands works in terminal but not when running script
databricks jobs run-now --job-id 1 --notebook-params '{"param1":"value1"}'

### this command works fine in terminal and when running script
databricks runs list

我得到的錯誤是:

Error: JSONDecodeError: Expecting value: line 1 column 59 (char 58)

同樣有趣的是,其他databricks-cli命令也可以在不需要JSON字符串參數的情況下工作。

我在問題中提供的腳本實際上並不代表我正在運行的腳本。

我實際上正在運行的腳本是這樣的:

#!/bin/bash

currentdate=`date +\%Y\%m\%d`
RUNDATE=$(date "--date=${currentdate} - ${stepsize} day" +%Y%m%d)

### this commands works in terminal but not when running script
databricks jobs run-now --job-id 1 --notebook-params '{"param1":"value1", "rundate":"$RUNDATE"}'

### this command works fine in terminal and when running script
databricks runs list

問題是將變量傳遞給JSON。

工作版本是這樣的:

#!/bin/bash

stepsize=1
currentdate=`date +\%Y\%m\%d`
RUNDATE=$(date "--date=${currentdate} - ${stepsize} day" +%Y%m%d)

echo $rundate 

databricks jobs run-now --job-id 263 --notebook-params '{"param1":"value1", "rundate":"'"$RUNDATE"'"}'

databricks runs list

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM