私は次のスクリプトを手元に持っていますが、エラーはあると思いますが、問題は、スクリプトは何も返さないが、スペルミスの単語を返すことになっているということです。私は、このコマンドを使用して、このスクリプトを実行私はaspellを使用してスペルチェックファイルをチェックするbashスクリプトを作成しようとしています
$ sh ./action.sh "{\"b64\":\"`base64 input.txt`\" }"
INPUT.TXT持っ6つのワード: 猫犬 elephentライオン moooseバグ
、それは
{ "result": "" }
を返しますが、私はそれを返すようにしたいです
{ "result": "elephent mooose " }
#!/bin/bash
#
# This script expects one argument, a String representation of a JSON
# object with a single attribute called b64. The script decodes
# the b64 value to a file, and then pipes it to aspell to check spelling.
# Finally it returns the result in a JSON object with an attribute called
# result
#
FILE=/home/user/output.txt
# Parse the JSON input ($1) to extract the value of the 'b64' attribute,
# then decode it from base64 format, and dump the result to a file.
echo $1 | sed -e 's/b64.://g' \
| tr -d '"' | tr -d ' ' | tr -d '}' | tr -d '{' \
| base64 --decode >&2 $FILE
# Pipe the input file to aspell, and then format the result on one line with
# spaces as delimiters
RESULT=`cat $FILE | aspell list | tr '\n' ' ' `
# Return a JSON object with a single attribute 'result'
echo "{ \"result\": \"$RESULT\" }"
のbash -xを使用してスクリプトを実行します。これは、変数RESULTの変更をよりよく追跡するのに役立ちます。 –
私はSHとしてみてください、それはファイルを出力し-x = /ホーム/フセイン/ output.txtと +エコー{ "B64": "Q2F0IGRvZyAKZWxlcGhhbnQgbGlvbgptb29zZSBidWcK"} + SED -es/B64://グラム + TR -d " + TR -d + TR -d} + TR -d { + base64で--decode /home/huseyin/output.txt +猫+ のaspellリスト+ /home/huseyin/output.txt TR \ n + RESULT = + echo {"result": ""} {"result": ""} –