shell(三十):执行任务shell脚本
2021/10/26 7:09:25
本文主要是介绍shell(三十):执行任务shell脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/bin/bash echo "----------------Java调用shell脚本执行客户端加解密任务,开始--------------------------" pwdDir=`pwd` cd $pwdDir echo "当前工程目录:"$pwdDir #查找数据库文件并读取数据 db_properties=`find $pwdDir -name "db.properties"` if [ -f "$db_properties" ];then #db_type=$(cat "$db_properties" | grep "dbType" | awk -F '=' '{print $2}') db_user=$(cat "$db_properties" | grep "userName" | awk -F '=' '{print $2}') db_pwd=$(cat "$db_properties" | grep "passWord" | awk -F '=' '{print $2}') echo "userName=$db_user" > client.conf echo "passWord=$db_pwd" >> client.conf tr -d '\r' < client.conf > client.txt fi db_user=$(cat client.txt | grep "user" | awk -F '=' '{print $2}') db_pwd=$(cat client.txt | grep "passWord" | awk -F '=' '{print $2}') echo $db_user echo $db_pwd client_installDir=`find /opt -name "AOEClient_auto"` cd $client_installDir/processor echo "进入processor目录:"$client_installDir/processor jarfile=`ls *.jar` echo $jarfile if [ -z "$jarfile" ];then echo "不存在jar包" exit 1 fi source /etc/profile echo "java -jar $jarfile --op=batchUpdate --user=$db_user --password=$db_pwd --taskId=$1 --threads=4" echo $db_user echo $db_pwd java -jar $jarfile --op=batchUpdate --user=$db_user --password=$db_pwd --taskId=$1 --threads=4 echo "----------------Java调用shell脚本执行客户端加解密任务,结束--------------------------"
优化后脚本:
#!/bin/bash echo "----------------Java调用shell脚本执行客户端加解密任务,开始--------------------------" pwdDir=`pwd` cd $pwdDir echo "当前工程目录:"$pwdDir #查找数据库文件并读取数据 db_properties=`find $pwdDir -name "db.properties"` if [ -f "$db_properties" ];then user=$(cat "$db_properties" | grep "userName" | awk -F '=' '{print $2}') password=$(cat "$db_properties" | grep "passWord" | awk -F '=' '{print $2}') client_installDir=`find /opt -name "AOEClient_auto"` cd $client_installDir/processor echo "进入processor目录:"$client_installDir/processor jarfile=`ls *.jar` echo $jarfile if [ -z "$jarfile" ];then echo "不存在jar包" exit 1 fi source /etc/profile echo "java -jar $jarfile --op=batchUpdate --user=$user --password=$password --taskId=$1 --threads=4" java -jar $jarfile --op=batchUpdate --user=$user --password=$password --taskId=$1 --threads=4 fi echo "----------------Java调用shell脚本执行客户端加解密任务,结束--------------------------"
备注:需要修改配置文件为unix格式,并且编码改成(UTF-8)
这篇关于shell(三十):执行任务shell脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-05小米13T Pro系统合集:性能与摄影的极致融合,值得你升级的系统ROM
- 2024-10-01基于Python+Vue开发的医院门诊预约挂号系统
- 2024-10-01基于Python+Vue开发的旅游景区管理系统
- 2024-10-01RestfulAPI入门指南:打造简单易懂的API接口
- 2024-10-01初学者指南:了解和使用Server Action
- 2024-10-01Server Component入门指南:搭建与配置详解
- 2024-10-01React 中使用 useRequest 实现数据请求
- 2024-10-01使用 golang 将ETH账户的资产平均分散到其他账户
- 2024-10-01JWT用户校验课程:从入门到实践
- 2024-10-01Server Component课程入门指南