我有一个shell脚本,它执行sql构建工作。
当从unix提示符手动调用它时,它正在执行并按预期给出结果。
但是当它从java调用时,它并没有完全执行。
手动执行:
MODIFY_PATCH_CREATION. ksh 118765CP_14052906_28112015134449_16
日志文件显示为:
Installing Patch for BATCH ID:118765 and PATCH NAME:CP_14052906_28112015134449_16
CP_14052906_28112015134449_16_RELEASE directory has been created
CP_14052906_28112015134449_16_INSTALL directory has been created
CP_14052906_28112015134449_16_ROLLBACK directory has been created
SQL and LOG directories have been created for INSTALL
INSTALL script is created
SQL and LOG directories have been created for ROLLBACK
ROLLBACK script is created
SQL files are created for INSTALL
SQL files are created for ROLLBACK
Patch installed Successfully..
但是如果我从java程序执行相同的操作,如下所示:
Java代码:
public class ShellTest{
public static void main(String a[]) throws Exception{
System.out.println("Hello kp");
Runtime.getRuntime().exec("MODIFY_PATCH_CREATION.ksh 118765 CP_14052906_28112015134449_16");
}
}
当作为java ShellTest执行时,日志只在一定程度上出现
Installing Patch for BATCH ID:118765 and PATCH NAME:CP_14052906_28112015134449_16
CP_14052906_28112015134449_16_RELEASE directory has been created
CP_14052906_28112015134449_16_INSTALL directory has been created
CP_14052906_28112015134449_16_ROLLBACK directory has been created
SQL and LOG directories have been created for INSTALL
INSTALL script is created
SQL and LOG directories have been created for ROLLBACK
ROLLBACK script is created
SQL files are created for INSTALL
Shell脚本代码:
#!/bin/bash
BATCH_ID=$1
echo "BATCH_ID: $BATCH_ID"
PATCH_NAME=$2
echo "PATCH_NAME: $PATCH_NAME"
echo "Creating patch for batch id $BATCH_ID"
ARBOR_USR=`echo $K_CAT_USERNAME`
dateTime=`date '+%d%m%Y_%H%M%S'`
PATCH_DIR=$ARBORDIR/cw/CPF_GSA_Modify
RELEASE_DIR=$ARBORDIR/cw/CPF_GSA_Modify/$2_RELEASE
INSTALL_DIR=$ARBORDIR/cw/CPF_GSA_Modify/$2_RELEASE/$2_INSTALL/
ROLLBACK_DIR=$ARBORDIR/cw/CPF_GSA_Modify/$2_RELEASE/$2_ROLLBACK/
##Logfile creation for install
cd $PATCH_DIR
touch $2_PATCH_log_$dateTime.txt
log_file=$PATCH_DIR/$2_PATCH_log_$dateTime.txt
echo "Installing Patch for BATCH ID:$BATCH_ID and PATCH NAME:$PATCH_NAME" >>$log_file
mkdir $2_RELEASE
echo "$2_RELEASE directory has been created" >>$log_file
cd $2_RELEASE
mkdir $2_INSTALL
echo "$2_INSTALL directory has been created" >>$log_file
mkdir $2_ROLLBACK
echo "$2_ROLLBACK directory has been created" >>$log_file
cd $INSTALL_DIR
mkdir SQL
mkdir LOG
echo "SQL and LOG directories have been created for INSTALL" >>$log_file
cp $PATCH_DIR/vge_cpf_gsa_mod_db_install.ksh $2_install.ksh
sed -i "s/vge_cpf_gsa_mod_db/$2/g" $2_install.ksh
echo "INSTALL script is created" >>$log_file
#cd SQL
#touch sql_list.sql
cd $ROLLBACK_DIR
mkdir SQL
mkdir LOG
echo "SQL and LOG directories have been created for ROLLBACK" >>$log_file
cp $PATCH_DIR/vge_cpf_gsa_mod_db_rollback.ksh $2_rollback.ksh
sed -i "s/vge_cpf_gsa_mod_db/$2/g" $2_rollback.ksh
echo "ROLLBACK script is created" >>$log_file
#cd SQL
touch sql_list.sql
cd $INSTALL_DIR/SQL/
echo 'Going to Connect to database'
touch display.log
sqlplus $ARBOR_USR/`cat $ARBORDIR/.arborpw`@$ORACLE_SID << THEEND >>display.log
set define off;
set linesize 3000;
set head off;
set feedback off;
spool CW_NEW_MRC.sql;
SELECT 'UPDATE RATE_RC a SET INACTIVE_DATE= (SELECT DISTINCT active_date FROM CW_PC_RR b WHERE a.element_id=b.element_id AND a.component_id=b.component_id and rownum<2) WHERE ELEMENT_ID='||MEMBER_ID||' AND COMPONENT_ID= '||COMPONENT_ID||' AND INACTIVE_date IS NULL ;' STATEMENT FROM CW_OLD_MRC_RATES WHERE batch_id=$BATCH_ID;
select 'INSERT INTO "RATE_RC" ("RATE_CLASS", "ELEMENT_ID", "COMPONENT_ID", "EQUIP_TYPE_CODE", "EQUIP_CLASS_CODE", "CLASS_OF_SERVICE_CODE", "TYPE_ID_RC", "BILLING_FREQUENCY", "CURRENCY_CODE", "RATE", "JURISDICTION", "DISTANCE_INCREMENT", "UNITS_TYPE", "UNITS_LOWER_LIMIT", "UNITS_UPPER_LIMIT", "UNITS_RATE", "POP_LOWER_LIMIT", "POP_UPPER_LIMIT", "DISTANCE_RATE", "ADD_IMPLIED_DECIMALS", "DATE_CREATED", "ACTIVE_DATE", "INACTIVE_DATE", "TEST_FLAG", "FOREIGN_CODE")VALUES ( '''|| RATE_CLASS||''','''||ELEMENT_ID||''','''||COMPONENT_ID||''','''||EQUIP_TYPE_CODE||''','''||EQUIP_CLASS_CODE||''','''||CLASS_OF_SERVICE_CODE||''','''||TYPE_ID_RC||''','''||BILLING_FREQUENCY||''','''||CURRENCY_CODE||''','''||RATE||''','''||JURISDICTION||''','''||DISTANCE_INCREMENT||''','''||UNITS_TYPE||''','''||UNITS_LOWER_LIMIT||''','''||UNITS_UPPER_LIMIT||''','''||UNITS_RATE||''','''||POP_LOWER_LIMIT||''','''||POP_UPPER_LIMIT||''','''||DISTANCE_RATE||''','''||ADD_IMPLIED_DECIMALS||''','''||to_char(DATE_CREATED ,'dd-mon-yyyy')||''','''||to_char(ACTIVE_DATE , 'dd-mon-yyyy')||''','''||to_char(INACTIVE_DATE , 'dd-mon-yyyy')||''','''||TEST_FLAG||''','''||FOREIGN_CODE || '''); ' statement from CW_PC_RR where batch_id=$BATCH_ID;
spool CW_NEW_DISCOUNT.sql;
SELECT 'UPDATE RATE_DISCOUNT RDIS SET RDIS.DATE_INACTIVE= (SELECT DISTINCT date_active FROM CW_PC_RD b WHERE RDIS .discount_id=b.discount_id and rownum<2) WHERE DISCOUNT_ID='||CR.DISCOUNT_ID|| ' AND billing_frequency= '||billing_frequency||' AND currency_code= '||currency_code||' AND DATE_INACTIVE IS NULL;' STATEMENT FROM CW_CPF_MODIFY_DISCOUNT_RATES CR where batch_id=$BATCH_ID;
SELECT 'INSERT INTO "RATE_DISCOUNT" ("DISCOUNT_ID", "RATE_CLASS", "RANGE_ORIGIN", "RANGE_TERMINUS", "BILLING_FREQUENCY", "CURRENCY_CODE", "DISCOUNT_PERCENT", "IMPLIED_DECIMALS", "DISCOUNT_AMOUNT", "DATE_ACTIVE", "DATE_INACTIVE", "DATE_CREATED", "LOOKUP_THRESHOLD_TIER_ID", "QUALIFYING_THRESHOLD_TIER_ID") VALUES ('''||DISCOUNT_ID||''','''|| RATE_CLASS||''','''||RANGE_ORIGIN||''','''||RANGE_TERMINUS||''','''||BILLING_FREQUENCY||''','''||CURRENCY_CODE||''','''||DISCOUNT_PERCENT||''','''||IMPLIED_DECIMALS||''','''||DISCOUNT_AMOUNT||''','''||to_char(DATE_ACTIVE , 'dd-mon-yyyy')||''','''||'' ||''','''||to_char(DATE_ACTIVE , 'dd-mon-yyyy')||''','''||LOOKUP_THRESHOLD_TIER_ID||''','''||QUALIFYING_THRESHOLD_TIER_ID||''');' statement from CW_PC_RD where batch_id=$BATCH_ID;
spool CW_NEW_UNIT_CREDIT.sql;
SELECT 'UPDATE RATE_UNIT_CR RDIS SET RDIS.DATE_INACTIVE = (SELECT DISTINCT date_active FROM CW_PC_RUC b WHERE b.unit_cr_id=rdis.UNIT_CR_ID and rownum<2) WHERE UNIT_CR_ID='||CR.DISCOUNT_ID|| ' AND billing_frequency= '||billing_frequency||' AND DATE_INACTIVE IS NULL;' STATEMENT FROM CW_CPF_MODIFY_UNITCREDIT_RATES CR where batch_id=$BATCH_ID;
SELECT 'INSERT INTO "RATE_UNIT_CR" ("UNIT_CR_ID", "RATE_CLASS", "RANGE_ORIGIN", "RANGE_TERMINUS", "BILLING_FREQUENCY", "CURRENCY_CODE", "UNITS_FREE", "AMOUNT_FREE", "DATE_ACTIVE", "DATE_INACTIVE") VALUES ('''||UNIT_CR_ID||''','''||RATE_CLASS||''','''||RANGE_ORIGIN||''','''||RANGE_TERMINUS||''','''||BILLING_FREQUENCY||''','''||CURRENCY_CODE||''','''||UNITS_FREE||''','''||AMOUNT_FREE||''','''||to_char(DATE_ACTIVE , 'dd-mon-yyyy')||''','''||to_char(DATE_ACTIVE , 'dd-mon-yyyy')||''');' statement from CW_PC_RUC where batch_id=$BATCH_ID;
spool CW_NEW_TARIFF_RATE.sql;
SELECT 'UPDATE TARIFF_RATE TR SET TR.DATE_INACTIVE = (SELECT DISTINCT date_active FROM CW_PC_TR b where tr.tariff_id=b.tariff_id and tr.bundle_id=b.bundle_id and rownum<2) WHERE TARIFF_ID='||CR.TARIFF_ID||' AND BUNDLE_ID='||CR.BUNDLE_ID||' AND DATE_INACTIVE IS NULL;' STATEMENT FROM CW_OLD_TARIFF_SELF_OPT_RATES CR;
SELECT 'INSERT INTO "TARIFF_RATE" ("TARIFF_ID", "BUNDLE_ID","CHARGE_AMOUNT","CURRENCY_CODE","IMPLIED_DECIMALS","DATE_ACTIVE","DATE_CREATED") VALUES ('''||TARIFF_ID||''','''||BUNDLE_ID||''','''||CHARGE_AMOUNT||''','''||CURRENCY_CODE||''','''||IMPLIED_DECIMALS||''','''||DATE_ACTIVE||''','''||DATE_CREATED||''');' statement from CW_PC_TR where batch_id=$BATCH_ID;
SELECT 'UPDATE TARIFF_RATE_BAND TRB SET TRB.STEP='||DECODE(STEP,'','NULL',STEP)||',TRB.RANGE_ORIGIN='||DECODE(RANGE_ORIGIN,'','NULL',RANGE_ORIGIN)||',TRB.RANGE_TERMINUS='||DECODE(RANGE_TERMINUS,'','NULL',RANGE_TERMINUS)||' WHERE TRB.TARIFF_ID='||TARIFF_ID||' AND TRB.AGGREGATION_KEY='||AGGREGATION_KEY||' AND TRB.BUNDLE_ID='||BUNDLE_ID||';' STATEMENT FROM CW_NEW_TARIFF_SELF_OPT_RATES where batch_id=$BATCH_ID;
spool CW_NEW_USAGE_RATES.sql;
SELECT 'UPDATE RATE_USAGE RU SET RU.INACTIVE_DT= (SELECT DISTINCT active_dt FROM CW_PC_RU b where ru.component_id=b.component_id and ru.type_id_usg=b.type_id_usg and ru.jurisdiction=b.jurisdiction and rownum<2 ) WHERE SEQNUM='||SEQNUM||'AND INACTIVE_DT IS NULL;' STATEMENT FROM CW_OLD_USAGE_RATES WHERE batch_id=$BATCH_ID;
select 'INSERT INTO "RATE_USAGE" ("SEQNUM", "RATE_CLASS", "TYPE_ID_USG", "BILL_CLASS","JURISDICTION","POINT_CLASS_TARGET","POINT_CLASS_ORIGIN","UNITS_INDICATOR","PROVIDER_CLASS","RATE_PERIOD","CURRENCY_CODE","ELEMENT_ID","EQUIP_TYPE_CODE","EQUIP_CLASS_CODE","CLASS_OF_SERVICE_CODE","FIXED_CHARGE_AMT","ADD_FIXED_AMT","ADD_UNIT_RATE","ACTIVE_DT","INACTIVE_DT","CREATE_DT","CHANGE_DT","CHANGE_WHO","INCREMENTAL_BANDS","RATE_UNITS_TYPE","DISTANCE_BAND_ID","ZONE_CLASS","ADD_IMPLIED_DECIMAL","IS_DEFAULT_RATE","COMPONENT_ID","BILLING_UNITS_TYPE","MIN_CHARGE_AMT","ADD_MIN_AMT") VALUES ('''||SEQNUM||''','''||RATE_CLASS||''','''||TYPE_ID_USG||''','''||BILL_CLASS||''','''||JURISDICTION||''','''||POINT_CLASS_TARGET||''','''||POINT_CLASS_ORIGIN||''','''||UNITS_INDICATOR||''','''||PROVIDER_CLASS||''','''||RATE_PERIOD||''','''||CURRENCY_CODE||''','''||ELEMENT_ID||''','''||EQUIP_TYPE_CODE||''','''||EQUIP_CLASS_CODE||''','''||CLASS_OF_SERVICE_CODE||''','''||FIXED_CHARGE_AMT||''','''||ADD_FIXED_AMT||''','''||ADD_UNIT_RATE||''','''||ACTIVE_DT||''','''||INACTIVE_DT||''','''||CREATE_DT||''','''||CHANGE_DT||''','''||CHANGE_WHO||''','''||INCREMENTAL_BANDS||''','''||RATE_UNITS_TYPE||''','''||DISTANCE_BAND_ID||''','''||ZONE_CLASS||''','''||ADD_IMPLIED_DECIMAL||''','''||IS_DEFAULT_RATE||''','''||COMPONENT_ID||''','''||BILLING_UNITS_TYPE||''','''||MIN_CHARGE_AMT||''','''||ADD_MIN_AMT || ''') ;' statement from CW_PC_RU where batch_id=$BATCH_ID;
select 'INSERT INTO "RATE_USAGE_BANDS" ("SEQNUM", "RATEBAND", "UNIT_RATE", "NUM_UNITS") VALUES ('''||SEQNUM||''','''||RATEBAND||''','''||UNIT_RATE||''','''||NUM_UNITS||''') ;' statement from CW_PC_RUB where batch_id=$BATCH_ID ORDER BY RATEBAND ASC;
spool CW_NEW_FUP.sql
SELECT 'UPDATE CW_VGE_FUP_REF_DATA SET TOLERANCE='''||TOLERANCE||''',PRICE_DELTA='''||PRICE_DELTA||''',FUP_LOWER='''||FUP_LOWER||''',ALLOWANCE='''||ALLOWANCE||''' WHERE UNIT_CR_ID='||UNIT_CR_ID|| ';' STATEMENT FROM CW_PC_FUP where batch_id=$BATCH_ID;
spool off
quit
THEEND
echo "SQL files are created for INSTALL" >>$log_file
echo "@CW_NEW_MRC.sql" >>sql_list.sql
echo "@CW_NEW_DISCOUNT.sql" >>sql_list.sql
echo "@CW_NEW_UNIT_CREDIT.sql" >>sql_list.sql
echo "@CW_NEW_TARIFF_RATE.sql" >>sql_list.sql
echo "@CW_NEW_USAGE_RATES.sql" >>sql_list.sql
echo "@CW_NEW_FUP.sql" >>sql_list.sql
cd $ROLLBACK_DIR/SQL/
echo 'Going to Connect to database'
touch display.log
sqlplus $ARBOR_USR/`cat $ARBORDIR/.arborpw`@$ORACLE_SID << THEEND >>display.log
clear buffer;
set define off;
set linesize 3000;
set head off;
set feed off
set feedback off;
COLUMN HEADING OFF
column HEADER truncated
column FOOTER truncated
spool CW_OLD_MRC.sql;
SELECT 'DELETE FROM RATE_RC WHERE INACTIVE_DATE=NULL AND ELEMENT_ID=' ||ELEMENT_ID||' AND COMPONENT_ID='||COMPONENT_ID|| '; ' STATEMENT FROM CW_PC_RR where batch_id=$BATCH_ID;
SELECT 'UPDATE RATE_RC SET INACTIVE_DATE=NULL WHERE ELEMENT_ID='||MEMBER_ID||' AND COMPONENT_ID= '||COMPONENT_ID||';' STATEMENT FROM CW_OLD_MRC_RATES where batch_id=$BATCH_ID;
spool CW_OLD_DISCOUNT.sql;
SELECT 'DELETE FROM RATE_DISCOUNT WHERE INACTIVE_DATE=NULL AND DISCOUNT_ID=' ||DISCOUNT_ID|| '; ' STATEMENT FROM CW_PC_RD where batch_id=$BATCH_ID;
SELECT 'UPDATE RATE_DISCOUNT RDIS SET RDIS.DATE_INACTIVE= null WHERE DISCOUNT_ID='||CR.DISCOUNT_ID|| ';' STATEMENT FROM CW_CPF_MODIFY_DISCOUNT_RATES CR where batch_id=$BATCH_ID;
spool CW_OLD_UNIT_CREDIT.sql;
SELECT 'DELETE FROM RATE_UNIT_CR WHERE INACTIVE_DATE=NULL AND UNIT_CR_ID=' ||UNIT_CR_ID|| '; ' STATEMENT FROM CW_PC_RUC where batch_id=$BATCH_ID;
SELECT 'UPDATE RATE_UNIT_CR RDIS SET RDIS.DATE_INACTIVE= null WHERE UNIT_CR_ID='||CR.DISCOUNT_ID|| ';' STATEMENT FROM CW_CPF_MODIFY_UNITCREDIT_RATES CR where batch_id=$BATCH_ID;
spool CW_OLD_TARIFF_RATE.sql;
SELECT 'DELETE FROM TARIFF_RATE WHERE DATE_INACTIVE= NULL AND TARIFF_ID='||CR.TARIFF_ID||' AND BUNDLE_ID='||CR.BUNDLE_ID||'; ' STATEMENT FROM CW_PC_TR CR where batch_id=$BATCH_ID;
SELECT 'UPDATE TARIFF_RATE TR SET TR.DATE_INACTIVE= NULL WHERE TARIFF_ID='||CR.TARIFF_ID||' AND BUNDLE_ID='||CR.BUNDLE_ID||' ;' STATEMENT FROM CW_OLD_TARIFF_SELF_OPT_RATES CR where batch_id=$BATCH_ID;
select 'UPDATE TARIFF_RATE_BAND TRB SET TRB.STEP='||decode(STEP,'','NULL',STEP)||',TRB.RANGE_ORIGIN='||decode(RANGE_ORIGIN,'','NULL',RANGE_ORIGIN)||',TRB.RANGE_TERMINUS='||decode(RANGE_TERMINUS,'','NULL',RANGE_TERMINUS)||' WHERE TRB.TARIFF_ID='||TARIFF_ID||' AND TRB.AGGREGATION_KEY='||AGGREGATION_KEY||' AND TRB.BUNDLE_ID='||BUNDLE_ID||';' statement from CW_OLD_TARIFF_SELF_OPT_RATES where batch_id=$BATCH_ID;
spool CW_OLD_USAGE_RATES.sql;
SELECT 'DELETE FROM RATE_USAGE WHERE SEQNUM = '||RU.SEQNUM|| ';' STATEMENT FROM CW_PC_RU RU where batch_id=$BATCH_ID;
SELECT 'DELETE FROM RATE_USAGE_BANDS WHERE SEQNUM = '||RUB.SEQNUM|| ';' STATEMENT FROM CW_PC_RUB RUB where batch_id=$BATCH_ID;
SELECT 'UPDATE RATE_USAGE RU SET RU.INACTIVE_DT= NULL WHERE SEQNUM='||SEQNUM||';' STATEMENT FROM CW_OLD_USAGE_RATES where batch_id=$BATCH_ID;
spool off
UPDATE CW_PC_BATCH_STATUS SET STATUS = 'PATCH_CREATED' WHERE BATCH_ID=$BATCH_ID;
quit
THEEND
echo "SQL files are created for ROLLBACK" >>$log_file
echo "@CW_OLD_MRC.sql" >>sql_list.sql
echo "@CW_OLD_DISCOUNT.sql" >>sql_list.sql
echo "@CW_OLD_UNIT_CREDIT.sql" >>sql_list.sql
echo "@CW_OLD_TARIFF_RATE.sql" >>sql_list.sql
echo "@CW_OLD_USAGE_RATES.sql" >>sql_list.sql
echo "Patch installed Successfully..">>$log_file
tar -cf $PATCH_DIR/$PATCH_NAME.tar $RELEASE_DIR
cp $PATCH_DIR/$PATCH_NAME.tar $ARBORDIR/cw/delivery
对我来说有些奇怪。请帮忙。
脚本有echo语句,这些语句没有指向日志,但Java程序没有使用脚本进程的输出,因此一旦输出缓冲区满了,脚本就会暂停。
如果希望脚本输出到控制台,即到与Java程序输出相同的输出目标,则需要使用ProcessBuilder。inheritIO()。
无论如何,您应该使用ProcessBuilder。引用流程的javadoc:
默认情况下,创建的子流程没有自己的终端或控制台。它的所有标准I/O(即stdin、stdout、stderr)操作都将重定向到父进程,在父进程中,可以通过使用方法获取的流来访问它们,这些方法包括。父进程使用这些流向子进程馈送输入并从中获取输出。由于某些本机平台仅为标准输入和输出流提供有限的缓冲区大小,如果不能及时写入子进程的输入流或读取子进程的输出流,可能会导致子进程阻塞,甚至死锁。
如果需要,还可以使用ProcessBuilder类的方法重定向子进程I/O。
从1.5开始,ProcessBuilder。start()
是创建流程的首选方法。
问题内容: 我想从PHP脚本执行系统上存在的Bash脚本。我的系统上有两个脚本。其中一个是称为at at 的PHP脚本,另一个是称为at at 的Bash脚本。 我的client.php脚本看起来像 我的睾丸看起来像 当我在终端上执行以下操作时 我在终端上得到以下输出 但是当我在打开页面时 我得到以下输出 即使执行了chmod + x testscript,我仍然收到此错误。 我如何从浏览器中获取
我正在使用谷歌表单来触发这个脚本。 当我用播放按钮运行脚本时,它工作得很好。 当我让提交触发器运行它时,复选框填充正常,但setValue日期没有。 我也试过了但是我得到了相同的结果。 最终目标是让J列在每次提交表单时填充A列中的快照格式日期 我需要此格式在另一张工作表上运行countIfs。 另一种选择是以某种方式将格式标记嵌入到CountIfs命令中,以便它们匹配。
问题内容: 我尝试谷歌搜索答案,但没有运气。 我需要使用我的超级计算机服务器,但是要运行我的python脚本,必须通过shell脚本执行。 例如我要执行 如何做到这一点? 问题答案: 只需确保python可执行文件在PATH环境变量中,然后在脚本中添加 细节: 在文件job.sh中,放入 执行此命令以使脚本可运行: 运行 :
我有SunOs 5.10 unix服务器,在那里我编写了一个脚本来执行java文件,如下所示 在这个脚本中,有很多代码,其中包括日志文件,以及在导出JAVA HOME之前添加的其他二进制文件类路径。但当我执行时,我得到以下错误 我更改了很多java版本,但都出现了相同的错误
问题内容: 我有一个读取输入的Shell脚本 我正在使用JAVA APi执行此Shell脚本 在Java控制台中,我可以看到输出 键入要检查的年份(4位数字),然后按[ENTER]: 现在,如何将值传递到我脚本中的Shell脚本中的实际问题是如何读取变量“ year” 我已经按照建议编辑了代码,但在我们更正的地方无法正常工作 问题答案: 要将执行脚本的Java程序中的值传递给脚本,请使用命令行参数
本文向大家介绍Android 从Gradle执行Shell脚本,包括了Android 从Gradle执行Shell脚本的使用技巧和注意事项,需要的朋友参考一下 示例 Shell脚本是一种非常通用的方法,可以将您的构建扩展到您能想到的任何东西。 例如,这是一个简单的脚本,用于编译protobuf文件并将结果java文件添加到源目录中以进行进一步编译: 此示例的“ pbScript.sh” shell