我正在嘗試撰寫一個腳本檔案,該檔案將使用 [cbq][1] 命令匯出一些資料,然后通過 [cbimport][2] 命令將這些資料匯入目標集群。我想以一種可以匯出大量資料并匯入另一個集群的方式來增強腳本。但是在我的本地機器上,它失敗了。實際上腳本卡在cbq命令的SELECT 命令中。
有人可以建議我怎么做。下面是我正在使用的測驗腳本。
echo "Hello World"
cbq -u Administrator -p Administrator -e "http://localhost:8093";
\REDIRECT temp.txt;
SELECT * FROM `sample.data` where id="106" --output="temp.txt";
\REDIRECT OFF;
cbimport json -c http://{target-cluster}:8091 -u Administrator -p Administrator -b sample.data -d file://C:\Users\myusername\Desktop\temp.txt -f list -g %docId%;
\EXIT;
以下是上述腳本的回應:
Hello World
Connected to : http://localhost:8093/. Type Ctrl-D or \QUIT to exit.
Path to history file for the shell : C:\Users\myuser\.cbq_history
并且卡在這里很長一段時間。
uj5u.com熱心網友回復:
特別是對于你的這個腳本,你有一個分號在 URL 之后終止 cbq 呼叫,所以它只是處于互動模式。
你想嘗試:
echo "Hello World"
cbq -u Administrator -p Administrator -e "http://localhost:8093" --output="temp.txt" -s "SELECT * FROM `sample.data` where id='106'"
# add processing to convert from redirected output to cbimport format
cbimport json -c http://{target-cluster}:8091 -u Administrator -p Administrator -b sample.data -d file://C:\Users\myusername\Desktop\temp.txt -f list -g %docId%
作為腳本中的 3 個命令。(注意陳述句中沒有使用雙引號,因為為 shell 選擇的引號是雙引號。你也可以反轉這個選擇。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/372725.html
