打印

老学员分享——编写shell脚本

[复制链接]
210|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
道子|  楼主 | 2018-8-22 10:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在实际项目中编写的几个小shell脚本

gradle build  启用守护进程,下次编译速度提高

#!bin/sh./gradlew build --daemon --parallel --offlineecho "enter enyone character"read characteradb install /Users/bjhl/Desktop/XXTT/xxtt-android/xuexitoutiao/build/outputs/apk/xuexitoutiao-zx-debug.apkcurl 请求链接

#!/bin/sh#此脚本是用来使用curl请求链接的#http://dev-app.*****.com/  dev#http://app.****.cn/    线上echo  "enter the request urltopic/list)"read urlecho  "enter the request paramspage=*&size=*&channel=**)"read paramscurl -d $params"&sig=****&client={\"appId\":\"****\",\"deviceId\":\"*****\",\"from\":\"**\",\"mac\":\"***\",\"model\":\"androidXT1085\",\"os\":\"android22\",\"version\":\"3\"}" "http://****.com/"$url脚本编译安装启动项目app

#!bin/shecho $(date +%Y-%m-%d:%H:%M:%S)source ~/.bash_profileecho "compiling..."gradle buildecho "uninstall..."adb uninstall  com.****.***echo "install..."adb install  /Users/bjhl/Desktop/***/**/***/build/outputs/apk/***-debug.apkecho "start MainActivity..."adb shell am start -n "com.****.***/com.***.***.MainActivity.java" -a android.intent.action.MAIN -c android.intent.category.LAUNCHERecho $(date +%Y-%m-%d:%H:%M:%S)网络请求 包含cookie

#!/bin/shecho -n "enter the request host: "read host # request host#cookieecho -n "use cookie ? (y/n)  "read is_cookiecookie=""#if need cookie setif [[ $is_cookie = "y" ]]; thenecho -n "input the cookie: "read input_cookiecookie=$input_cookiefiecho -n "need post? (y/n)  "read tag#http get if tag = nif [[ $tag = "n" ]]; thenif [[ $cookie != "" ]]; thencurl $host -b$cookieelsecurl $hostfiexit 0fi#the json data need to postdata=""#the input value pairkv_pair=""while true; doif [[ $tag = "y" ]]; then#input keyecho -n "key :  "read key# set break condition key = gameover 这里是一个循环结束的标志.输入这个标志表示我需要传递的json数据已经全部写进去了if [[ $key = "gameover" ]]; then#complete the json format, %,*  start at right side and romove the first ','kv_pair=${kv_pair%,*}#this is the last data to postdata="{"$kv_pair"}"echo "post data is: $data and exce the curl cmd"#curl $host -d$databreak;fi#encode with ""key='"'$key'"'#input valueecho -n "value : "read value#encode value with ""value='"'$value'"'#set value pair and extends itselfkv_pair="$kv_pair"$key":"$value","echo "$kv_pair"fidone#do http postif [[ $cookie != "" ]]; thencurl $host -d$data -b$cookieelsecurl $host -d$datafi

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

443

主题

448

帖子

0

粉丝