jasonboetcher
asked on
Problem w/DOS Escape Character ^
I have the following script; all lines print to the output file except for the Prompt19 line and I don't understand why.
REM Put currentDate into YYYY-MM-DD format
REM Put firstDayOfMonth into YYYY-MM-DD format
REM Put currentYear into YYYY format
for /F "tokens=2-4 delims=/ " %%A in ('date/T') do (
set currentDate=%%C-%%A-%%B
set firstDayOfMonth=%%C-%%A-01
set currentYear=%%C
)
REM Put currentMonth in MMM format
REM https://www.experts-exchange.com/questions/21174359/DOS-MMM-Date-Format.html#12352023
for /f "tokens=2 delims=/ " %%a in ('date /t') do (
if "%%a" == "1" set currentMonth=JAN
if "%%a" == "2" set currentMonth=FEB
if "%%a" == "3" set currentMonth=MAR
if "%%a" == "4" set currentMonth=APR
if "%%a" == "5" set currentMonth=MAY
if "%%a" == "6" set currentMonth=JUN
if "%%a" == "7" set currentMonth=JUL
if "%%a" == "8" set currentMonth=AUG
if "%%a" == "9" set currentMonth=SEP
if "%%a" == "10" set currentMonth=OCT
if "%%a" == "11" set currentMonth=NOV
if "%%a" == "12" set currentMonth=DEC
)
REM Use the ^ character to allow the | to be written to the output file.
REM https://www.experts-exchange.com/questions/21173759/DOS-Echo-a-Bar-Character.html
cd d:\impromptu\reprunner
echo [Catalog]>>hnb_monthly_rep runner.ini
echo catalog1 = d:\impromptu\catalog\new_m ts_11.cat> >hnb_month ly_reprunn er.ini
echo catname1 = user>>hnb_monthly_reprunne r.ini
echo catpwd1 = >>hnb_monthly_reprunner.in i
echo dbname1 = rgw_user>>hnb_monthly_repr unner.ini
echo dbpwd1 = intranet>>hnb_monthly_repr unner.ini
echo [Daily Reports]>>hnb_monthly_repr unner.ini
echo Report1=d:\impromptu\bin\a ccounting. imr>>hnb_m onthly_rep runner.ini
echo Prompt1=%currentDate%^|%cu rrentDate% >>hnb_mont hly_reprun ner.ini
echo Report2=d:\impromptu\bin\c anceled_me ssages.imr >>hnb_mont hly_reprun ner.ini
echo Prompt2=%currentDate%>>hnb _monthly_r eprunner.i ni
echo Report3=d:\impromptu\bin\c redit_part y_not-on-f ile.imr>>h nb_monthly _reprunner .ini
echo Prompt3=%currentMonth%^|%c urrentYear %>>hnb_mon thly_repru nner.ini
echo Report4=d:\impromptu\bin\f ed_transac tion_journ al.imr>>hn b_monthly_ reprunner. ini
echo Prompt4=%currentDate%>>hnb _monthly_r eprunner.i ni
echo Report5=d:\impromptu\bin\g eneral_led ger_transa ction.imr> >hnb_month ly_reprunn er.ini
echo Prompt5=%currentDate%>>hnb _monthly_r eprunner.i ni
echo Report6=d:\impromptu\bin\g eneral_led ger_transa ction_cmln .imr>>hnb_ monthly_re prunner.in i
echo Prompt6=%currentDate%>>hnb _monthly_r eprunner.i ni
echo Report7=d:\impromptu\bin\o perator_fi le_change. imr>>hnb_m onthly_rep runner.ini
echo Prompt7=%currentDate%^|%cu rrentDate% >>hnb_mont hly_reprun ner.ini
echo Report8=d:\impromptu\bin\o perator_in activity.i mr>>hnb_mo nthly_repr unner.ini
echo Prompt8=15>>hnb_monthly_re prunner.in i
echo Report9=d:\impromptu\bin\o perator_st atistics.i mr>>hnb_mo nthly_repr unner.ini
echo Prompt9=%currentDate%>>hnb _monthly_r eprunner.i ni
echo Report10=d:\impromptu\bin\ party_not_ on_file.im r>>hnb_mon thly_repru nner.ini
echo Prompt10=%firstDayOfMonth% ^|%current Date%>>hnb _monthly_r eprunner.i ni
echo Report11=d:\impromptu\bin\ pin_expira tion.imr>> hnb_monthl y_reprunne r.ini
echo Prompt11=2000-01-01^|%curr entDate%>> hnb_monthl y_reprunne r.ini
echo Report12=d:\impromptu\bin\ pin_file_c hange.imr> >hnb_month ly_reprunn er.ini
echo Prompt12=%currentDate%^|%c urrentDate %>>hnb_mon thly_repru nner.ini
echo Report13=d:\impromptu\bin\ skip_trans action.imr >>hnb_mont hly_reprun ner.ini
echo Prompt13=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report14=d:\impromptu\bin\ stop_actio n_statisti cs.imr>>hn b_monthly_ reprunner. ini
echo Prompt14=%currentDate%^|%c urrentDate %>>hnb_mon thly_repru nner.ini
echo Report15=d:\impromptu\bin\ stop_trans action.imr >>hnb_mont hly_reprun ner.ini
echo Prompt15=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report16=d:\impromptu\bin\ straight_t hrough.imr >>hnb_mont hly_reprun ner.ini
echo Prompt16=%currentDate%^|AL L>>hnb_mon thly_repru nner.ini
echo Report17=d:\impromptu\bin\ swf_daily_ inbound_me ssage_type .imr>>hnb_ monthly_re prunner.in i
echo Prompt17=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report18=d:\impromptu\bin\ swf_daily_ outbound_m essage_typ e.imr>>hnb _monthly_r eprunner.i ni
echo Prompt18=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report19=d:\impromptu\bin\ unacknowle dged_pin.i mr>>hnb_mo nthly_repr unner.ini
echo Prompt19=ALL^|2003-01-01^| %currentDa te%^|ALL^| 0>>hnb_mon thly_repru nner.ini
echo Report20=d:\impromptu\bin\ general_le dger_12001 050204.IMR >>hnb_mont hly_reprun ner.ini
echo Prompt20=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report21=d:\impromptu\bin\ general_le dger_13000 050204.IMR >>hnb_mont hly_reprun ner.ini
echo Prompt21=%currentDate%>>hn b_monthly_ reprunner. ini
echo Report22=d:\impromptu\bin\ relationsh ip_file_ch ange.imr>> hnb_monthl y_reprunne r.ini
echo Prompt22=%currentDate%^|%c urrentDate %>>hnb_mon thly_repru nner.ini
echo Report23=d:\impromptu\bin\ repetitive _file_chan ge.imr>>hn b_monthly_ reprunner. ini
echo Prompt23=%currentDate%^|%c urrentDate %>>hnb_mon thly_repru nner.ini
echo Report24=d:\impromptu\bin\ standing_o rder_file_ change.imr >>hnb_mont hly_reprun ner.ini
echo Prompt24=%currentDate%^|%c urrentDate %>>hnb_mon thly_repru nner.ini
echo Report25=d:\impromptu\bin\ large_doll ar_custome r_usage.im r>>hnb_mon thly_repru nner.ini
echo Prompt25=%currentDate%^|50 0000>>hnb_ monthly_re prunner.in i
REM Put currentDate into YYYY-MM-DD format
REM Put firstDayOfMonth into YYYY-MM-DD format
REM Put currentYear into YYYY format
for /F "tokens=2-4 delims=/ " %%A in ('date/T') do (
set currentDate=%%C-%%A-%%B
set firstDayOfMonth=%%C-%%A-01
set currentYear=%%C
)
REM Put currentMonth in MMM format
REM https://www.experts-exchange.com/questions/21174359/DOS-MMM-Date-Format.html#12352023
for /f "tokens=2 delims=/ " %%a in ('date /t') do (
if "%%a" == "1" set currentMonth=JAN
if "%%a" == "2" set currentMonth=FEB
if "%%a" == "3" set currentMonth=MAR
if "%%a" == "4" set currentMonth=APR
if "%%a" == "5" set currentMonth=MAY
if "%%a" == "6" set currentMonth=JUN
if "%%a" == "7" set currentMonth=JUL
if "%%a" == "8" set currentMonth=AUG
if "%%a" == "9" set currentMonth=SEP
if "%%a" == "10" set currentMonth=OCT
if "%%a" == "11" set currentMonth=NOV
if "%%a" == "12" set currentMonth=DEC
)
REM Use the ^ character to allow the | to be written to the output file.
REM https://www.experts-exchange.com/questions/21173759/DOS-Echo-a-Bar-Character.html
cd d:\impromptu\reprunner
echo [Catalog]>>hnb_monthly_rep
echo catalog1 = d:\impromptu\catalog\new_m
echo catname1 = user>>hnb_monthly_reprunne
echo catpwd1 = >>hnb_monthly_reprunner.in
echo dbname1 = rgw_user>>hnb_monthly_repr
echo dbpwd1 = intranet>>hnb_monthly_repr
echo [Daily Reports]>>hnb_monthly_repr
echo Report1=d:\impromptu\bin\a
echo Prompt1=%currentDate%^|%cu
echo Report2=d:\impromptu\bin\c
echo Prompt2=%currentDate%>>hnb
echo Report3=d:\impromptu\bin\c
echo Prompt3=%currentMonth%^|%c
echo Report4=d:\impromptu\bin\f
echo Prompt4=%currentDate%>>hnb
echo Report5=d:\impromptu\bin\g
echo Prompt5=%currentDate%>>hnb
echo Report6=d:\impromptu\bin\g
echo Prompt6=%currentDate%>>hnb
echo Report7=d:\impromptu\bin\o
echo Prompt7=%currentDate%^|%cu
echo Report8=d:\impromptu\bin\o
echo Prompt8=15>>hnb_monthly_re
echo Report9=d:\impromptu\bin\o
echo Prompt9=%currentDate%>>hnb
echo Report10=d:\impromptu\bin\
echo Prompt10=%firstDayOfMonth%
echo Report11=d:\impromptu\bin\
echo Prompt11=2000-01-01^|%curr
echo Report12=d:\impromptu\bin\
echo Prompt12=%currentDate%^|%c
echo Report13=d:\impromptu\bin\
echo Prompt13=%currentDate%>>hn
echo Report14=d:\impromptu\bin\
echo Prompt14=%currentDate%^|%c
echo Report15=d:\impromptu\bin\
echo Prompt15=%currentDate%>>hn
echo Report16=d:\impromptu\bin\
echo Prompt16=%currentDate%^|AL
echo Report17=d:\impromptu\bin\
echo Prompt17=%currentDate%>>hn
echo Report18=d:\impromptu\bin\
echo Prompt18=%currentDate%>>hn
echo Report19=d:\impromptu\bin\
echo Prompt19=ALL^|2003-01-01^|
echo Report20=d:\impromptu\bin\
echo Prompt20=%currentDate%>>hn
echo Report21=d:\impromptu\bin\
echo Prompt21=%currentDate%>>hn
echo Report22=d:\impromptu\bin\
echo Prompt22=%currentDate%^|%c
echo Report23=d:\impromptu\bin\
echo Prompt23=%currentDate%^|%c
echo Report24=d:\impromptu\bin\
echo Prompt24=%currentDate%^|%c
echo Report25=d:\impromptu\bin\
echo Prompt25=%currentDate%^|50
I just cut and past your exact line and didn't have a problem with it. Try as a single line and see if it works for you.
ASKER
I did the echo as a line command and it works as well; try pasting it into a .bat file and running it and look at the output. The line in question is missing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm not sure I understand why this works but it does; thanks!