HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About

batch script

January 8, 2009|ant, dos, maven, script|電腦編程2
Home » Blog » 電腦編程 » batch script

因為唔同platfrom… 係linux/max 上可以行既shell script,
係windows 係可以用cygwin 去行
可惜, 如果用 eclipse > ant build , 個ant call *.sh 就出事
寫(translate)左一個好無聊既 batch script
(被)玩左一個下午,就係因為唔識寫script, 同埋個help 係 %~dpnI 唔係 %%~dpnI ….
記錄一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
::-----------------------------------------------------------::
::                  CONFIGURATION SCRIPT
::
:: Script copies file.type.{DEPLOY} to file.type
:: Where {DEPLOY} is one of PRODUCTION|STAGING|QA|INTERNAL|DEV
::
:: modify from config.sh to windows environment
::
:: Author: Steve Chan steve.chan@pxxxxl.com.au
:: $Id: config.bat,v 1.0 2009/01/07 13:24:57 steve Exp $
::-----------------------------------------------------------::
 
::  check that we were supplied two parameters
@ECHO OFF
IF NOT (%1)==() SET DEST=%1
IF NOT (%2)==() SET DEPLOY=%2
 
::@ECHO ON
ECHO.DIR /b /s %DEST%*.%DEPLOY%
 
:: copy all filenames with extension . to a temporary file
DIR /b /s %DEST%\*.%DEPLOY% > tmp.out
 
:: iterate through the filenames and copy to the filename root
FOR /f %%I IN (tmp.out) DO (
  ECHO.copy: %%I %%~dpnI
  COPY %%I %%~dpnI
)
 
:: get rid of the temporary file
del tmp.out

part of maven.xml

XHTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<goal name="config">
  <echo>CONFIGURATION BUNDLE USED: ${configuration.bundle}</echo>
  <echo>${configuration.script} ${basedir} ${configuration.bundle}</echo>
 
  <!-- distinguish windows environment, using config.bat instead of config.sh -->
  <!-- orginal script-->
  <!--
  <ant:exec dir="${basedir}" executable="sh">
    <ant:arg line="${configuration.script} ${basedir} ${configuration.bundle}"/>
  -->
  <ant:condition property="os.windows.family">
      <ant:os family="windows"/>
   </ant>
   <j:choose>
      <j:when test="${os.windows.family}">
          <ant:exec dir="${basedir}" executable="cmd">
              <ant:arg line="/c config.bat ${basedir} ${configuration.bundle}" />
              <echo>Windows Environment: config.bat ${basedir} ${configuration.bundle}</echo>
          </ant:exec>
      </j:when>
      <j:otherwise>
          <ant:exec dir="${basedir}" executable="sh">
            <ant:arg line="${configuration.script} ${basedir} ${configuration.bundle}" />
          </ant:exec>
      </j:otherwise>
    </j:choose>
   <!-- end modification for windows environment -->
</goal>

 

January 8, 2009 user

Recent Posts

  • Serverless Cloud Run Development: Challenge Lab
    Serverless Cloud Run Development: Challenge LabFebruary 7, 2021
  • ionic 4: capacitor & pwa
    ionic 4: capacitor & pwaJanuary 2, 2019
  • Open file limit of tomcat and mysql in Linux server
    Open file limit of tomcat and mysql in Linux serverDecember 1, 2018

Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)June 8, 2015
  • assembly
    assemblyFebruary 11, 2006
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題….October 28, 2004
← 新工作
今日好唔開心 →

2 Responses to batch script

  • 斌 January 16, 2009

    哦,原來係呢個問題呀嘛~

    Reply
  • HanG January 19, 2009

    ….. 好野… 咁都知道係乜野問題 ……..

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.




最新文章 Recent Posts

  • Serverless Cloud Run Development: Challenge Lab
  • ionic 4: capacitor & pwa
  • Open file limit of tomcat and mysql in Linux server
  • avoid subquery in mysql update statement
  • hacktoberfest

最新留言 Recent Comments

  • admin on LikeCoin
  • Edmond on LikeCoin
  • John Smith on Install macOS High Sierra on VMware
  • admin on Install macOS High Sierra on VMware
  • nana on Install macOS High Sierra on VMware




熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 嫁人要嫁工程師
    嫁人要嫁工程師 April 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

January 2009
M T W T F S S
  « Dec   Feb »  
 1234
567891011
12131415161718
19202122232425
262728293031  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved