简体   繁体   English

如何编写 shell 脚本以从文件中为 arguments 调用 function?

[英]How to write shell script for chaincode invoke function for arguments from file?

I want to invoke chaincode to write data for 10 records automatically with using bash script and arguments for chaincode can be able to take from txt file.But, chaincode does not write to ledger from file, it writes only value "line1" and "line2".我想使用 bash 脚本和 arguments 调用链码自动写入 10 条记录的数据,链码可以从 txt 文件中获取。但是,链码不会从文件写入分类帐,它只写入值“line1”和“line2” ”。

#!/bin/bash while read -r line1 <&3 && read -r line2 <&4; do
peer chaincode invoke -c '{"Args":["createDocRecord", "$line1" , "$line2"]}' -o orderer.example.com:7050 -C bloom-filter-channel -n bloom-filter --peerAddresses peer0.org2.example.com:9051  done 3<scripts/10.txt 4<scripts/data10.txt`

Why it does not take string values from txt file?为什么它不从 txt 文件中获取字符串值?

Try to set a timeout.尝试设置超时。 You are probably running the invoke while the first transaction is not validated and committed yet, I don't know how you configured your network.您可能正在运行调用,而第一个事务尚未验证和提交,我不知道您是如何配置网络的。

So do someting like:所以做一些类似的事情:

peer chaincode invoke -c '{"Args":["createDocRecord", "$line1" , "$line2"]}' -o orderer.example.com:7050 -C bloom-filter-channel -n bloom-filter --peerAddresses peer0.org2.example.com:9051  done 3<scripts/10.txt 4<scripts/data10.txt`

timeout 5

repeat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM