当前位置:网站首页>Shell script return value with which output
Shell script return value with which output
2022-07-03 18:34:00 【-Abu-】
I want to return to one false that will do , The result is a node Path out , The script is as follows :
#!/bin/bash
# Tips “ Please enter a name ” And wait for 30 second , Save user input into variables name in
read -t 30 -p " Please enter your mobile number :" phone
# Tips “ Please input a password ” And wait for 30 second , Save user input into variables pwd in , Input content is hidden
read -t 30 -s -p " Please enter the user password :" password
echo -e "\n"
# Login interface
loginRes=`curl -X POST "'Content-type':'application/json'" -d '{"api":"login.pw","params":{"loginId":'$phone',"password":'$password',"appId":"yptb"},"nonce":"uuid","sign":"sign","version":"1.0","timestamp":"230993499430010"}' https://apigw.xxxx.com/request`
echo " Login return information :$loginRes"
function getJsonValueByNode() {
if which node; then
local json="$1"
local key="$2"
node -pe "JSON.stringify(JSON.parse(process.argv[1]).$key)" "$json" | awk '{print ($0 == "undefined" ? "null" : $0)}'
return 0
else
return 1
fi
}
value=$(getJsonValueByNode $loginRes "result.success")
echo " Variable :$value"
Solution :
take which Of output to /dev/null in , Reference resources :How can I check if a program exists from a Bash script? - Stack Overflow
边栏推荐
- 204. Count prime
- [Godot] add menu button
- Summary and Reflection on the third week of winter vacation
- Sensor 调试流程
- Nodejs (01) - introductory tutorial
- 2022-2028 global marking ink industry research and trend analysis report
- Mysql45 lecture learning notes (II)
- 198. Looting - Dynamic Planning
- Read the paper glodyne global topology preserving dynamic network embedding
- Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
猜你喜欢
Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
[enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
AcWing 271. 杨老师的照相排列【多维DP】
The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
Win32: analyse du fichier dump pour la défaillance du tas
Golang string (string) and byte array ([]byte) are converted to each other
Redis cache avalanche, penetration, breakdown
Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing
Kratos微服务框架下实现CQRS架构模式
Mysql45 lecture learning notes (II)
随机推荐
Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
189. Rotation array
PHP determines which constellation it belongs to today
[combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
Multifunctional web file manager filestash
Valentine's day, send you a little red flower~
MySQL duplicate check
Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
TypeScript 官网教程
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
199. Right view of binary tree - breadth search
图像24位深度转8位深度
[combinatorics] generating function (example of generating function | calculating generating function with given general term formula | calculating general term formula with given generating function)
[combinatorics] exponential generating function (example 2 of solving multiple set permutation with exponential generating function)
Typescript official website tutorial
How to quickly view the inheritance methods of existing models in torchvision?
Enterprise custom form engine solution (12) -- form rule engine 2
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]