Computing.Net > Forums > Disk Operating System > [DOS] running a command within a ba

[DOS] running a command within a ba

Reply to Message Icon

Original Message
Name: sajjadr21
Date: November 19, 2003 at 00:51:04 Pacific
Subject: [DOS] running a command within a ba
OS: XP
CPU/Ram: 504 MB
Comment:

hello

i want to run dos command from a batch file. it does not seem to give me the desired results.

any suggestion geeks?

/s

command
=======
c:\j2sdk1.4\java -jar c:\saxon\saxon7.jar "%%p\%look4file%" "%style%" > "%%p\1.html"

batch file
==========
@echo off
set topdir=C:\kix\Enterprise0311141\Enterprise
set tempdir=C:\temp
set style=C:\tree.xsl
set look4file=xmlinterlinks.xml

echo %topdir%> "%tempdir%\dirlist.txt"
dir "%topdir%" /s /b /ad >> "%tempdir%\dirlist.txt"

for /F "delims=*" %%p IN (%tempdir%\dirlist.txt) do if exist "%%p\%look4file%" c:\j2sdk1.4\java -jar c:\saxon\saxon7.jar "%%p\%look4file%" "%style%" > "%%p\1.html"



Report Offensive Message For Removal

Response Number 1
Name: IVO
Date: November 19, 2003 at 02:04:11 Pacific
Subject: [DOS] running a command within a ba
Reply: (edit)

The For command, managing your statement that does not perform as extpected, results in a total length of the line exceeding 127 characters. That may lead to unpredictable results. So I suggest you short the line breaking it into two parts as below, i.e. insert a ( after do and then a CR/LF ending the second line with a ):

for /F "delims=*" %%p IN (%tempdir%\dirlist.txt) do (
if exist "%%p\%look4file%" c:\j2sdk1.4\java -jar c:\saxon\saxon7.jar "%%p\%look4file%" "%style%" > "%%p\1.html")

Now the total length is 53 + 112 from the original 163.


Report Offensive Follow Up For Removal

Response Number 2
Name: sajjadr21
Date: November 19, 2003 at 03:50:27 Pacific
Subject: [DOS] running a command within a ba
Reply: (edit)

Thanks IVO.

Infact I had the issue with the java path and saxon path. I changed the paths and its working fine.

It is also a good thought to break the line into pieces.

Cheers


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: [DOS] running a command within a ba

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software