Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello, help on two questions will be highly appreciated.
Question 1:
How to check the result of last DOS command in a .bat file ?
For example, in miketex I use@echo off
echo looking for latex package %1
initexmf --find-latex-input %1.styHow can I proceed the following command
initexmf --update-fndb
only when the search of the last command returns no result ?In unix, to know the result of last command, I can direct the output by "> /dev/null" then check "$status",
but how to do the same thing in DOS ?
Question 2:I use cgywin so "make" works very well for
my PC with OS win2k. But I noticed sth strange:
If I use "ps2pdf $(File).ps" directly from DOS commandline input, then the result is perfect. But if I put the above command on a Makefile,for example:pf:
(tab) ps2pdf $(File).psThen my PC refused to do the task, and I got
error message like:
make: *** [pf] Error 128
The dinamic link library cygz.dll could not be found in the specified path ....I search my PC and found no cygz.dll file at all. Can someone tell me why the same command works for commandline input but does not work in a Makefile? (both commands were
issued from the same DOS window)Thanks again.

1) The DOS equivalent of $status is errorlevel. It is returned as a number and used in a very strange way. This will only work if your program returns a non zero value. See
if /?
This varies depending on whether you are using NT or Win9x or DOS6.x
2) The problem is $(File). Make looks for a symbol File in the makefile. Try using $$ in place of $.

Thanks to CUP' reply. The symbol looks like a very fast CPU :)
The ERRORLEVEL works.
For the second question, actually in
commandline input I substitued a true file name for $(File), while in Makefile I assigned a value to the variable named File.It is kind of strange that the same way worked in the unix env, while not work for cygwin make. I am not sure if "cygwin make" has a bug though. Those commands like ps2pdf, dvips etc have different options for different OS. But I did not think I use the options wrong.

Makefiles can be a pain sometimes. It is the only programming system I use where the starting point is in the middle.
I've never used cygwin so I don't know the root cause of the problem. Have you tried -DFile=xxx from the make command line? If that works then the definition of File is missing. You'll need to add in a File= somewhere.

I solved the second problem. (Pose here in case someone may have the same problem.)
Actually the cygwin I installed should be upgraded to higher version to agree with the version of my Miktex.
After upgrading, I have the required cygz.dll, so no more problems exist for the makefile.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |