Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: nt script

RE: nt script

From: Kevin Lange <klange_at_ppoone.com>
Date: Fri, 07 Mar 2003 11:19:49 -0800
Message-ID: <F001.005639C2.20030307111949@fatcity.com>


If you just do a HELP COMMAND, where command is the name of the command you need help on, you can find out as much as you really need to know about BATCH.   In your sample of FOR /F "TOKENS=1,2*" %%A IN ('DATE/T') DO SET DATE=%%B

They were trying to set a variable called DATE based on the system date.  

First of all , %%A should be %A and %%B should be %B if you are running this command in a command line. If you place it in a batch file the way you have it, it will work.  

First 2 values from the DATE/T command are placed in the variables %A and %B. Then, for each line returned in this command (1), you set the variable DATE equal to the second returned value (%B).  

For example, today the DATE/T returns 'Fri 03/07/2003". Therefore, %A gets set to FRI and %B gets set to 03/07/2003. When your command completes, the variable DATE will be equal to %B or 03/07/2003.  



This was determined by doing a help on the FOR command:  

help for  

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
 

    or, if usebackq option present:  

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]
 

    filenameset is one or more file names. Each file is opened, read     and processed before going on to the next file in filenameset.     Processing consists of reading in the file, breaking it up into     individual lines of text and then parsing each line into zero or     more tokens. The body of the for loop is then called with the     variable value(s) set to the found token string(s). By default, /F     passes the first blank separated token from each line of each file.     Blank lines are skipped. You can override the default parsing     behavior by specifying the optional "options" parameter. This     is a quoted string which contains one or more keywords to specify     different parsing options. The keywords are:  

        eol=c           - specifies an end of line comment character
                          (just one)
        skip=n          - specifies the number of lines to skip at the
                          beginning of the file.
        delims=xxx      - specifies a delimiter set.  This replaces the
                          default delimiter set of space and tab.
        tokens=x,y,m-n  - specifies which tokens from each line are to
                          be passed to the for body for each iteration.
                          This will cause additional variable names to
                          be allocated.  The m-n form is a range,
                          specifying the mth through the nth tokens.  If
                          the last character in the tokens= string is an
                          asterisk, then an additional variable is
                          allocated and receives the remaining text on
                          the line after the last token parsed.
        usebackq        - specifies that the new semantics are in force,
                          where a back quoted string is executed as a
                          command and a single quoted string is a
                          literal string command and allows the use of
                          double quotes to quote file names in
                          filenameset.

 
 

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Kevin Lange
  INET: klange_at_ppoone.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Mar 07 2003 - 13:19:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US