Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2007

Tip: Looking for answers? Try searching our database.

NMake question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
בועז אופק - 15 Aug 2007 08:34 GMT
Hello;

I am using nmake.exe (which comes with Visual Studio).
I have 2 programs (which I am not the owner of their source).

I run "prog1.exe <param>", which  returns with an exit code according to the
<param>.

Then I want to run "prog2.exe <prog1.exe exit code>".

Can this be done with nmake.exe?!
I haven't found the solution yet.

Thanks in advanced,
Boaz Offek
Justin Chase - 16 Aug 2007 14:41 GMT
I'm not really familiar with NMake but I can say that you might want
to try using MSBuild for this sort of thing instead, build some .NET
(or COM) classes to perform your tasks instead of passing around
values between executables. However if you're stuck using exe's to
communicate with each other like the above a simple batch file will
probably do the trick. The error code of an application will be set
into an environment variable called ERRORLEVEL, here is an example of
a batch script that solves your problem:

set PARM1="..."

prog1.exe %PARM1%
prog2.exe %ERRORLEVEL%

So if your codes main function in prog1 looks like this:

int main(string[] args)
{
  return args.Length;
}

then %ERRORLEVEL% will be 1 when calling prog2. It should be noted
that most applications will return 0 when an application runs with no
errors and some number greater than 0 if an error has occurred. The
higher the number the more severe the error.

So you might consider having your batch file like this:

set PARM1="..."

prog1.exe %PARM1%
if %ERRORLEVEL% GTR 0 (
   prog2.exe %ERRORLEVEL%
)

So all you need to do put this code into a file with the file
extension of ".bat" and then you can run this batch file by double
clicking it or as an executable from a command line. Hope that helps!
בועז אופק - 18 Aug 2007 06:54 GMT
> I'm not really familiar with NMake but I can say that you might want
> to try using MSBuild for this sort of thing instead, build some .NET
[quoted text clipped - 34 lines]
> extension of ".bat" and then you can run this batch file by double
> clicking it or as an executable from a command line. Hope that helps!

Hello Justin;

First of all, thanks for the reply.

Second, I must say that this wasn't the answer I was looking for, as I have
tried it already, and I have discivered that the problem is much deeper. I
will post now the full problem and answer, hopefully it will help someone
sometime;

Problem:
- Inside a makefile, I was, for each file which meets a condition, to run a
program, get its return value and use it as a parameter for another
program(s). (please see original post)
- nmake will not preserve ERRORLEVEL environmental, or any other
environmentals from the running of prog1.exe
- prog2.exe needs more parameters which are dependant upon the makefile,
like: filename (from the rule) etc.

Solution:
Create a batch file "on the fly" using inline files. It's not very "clean"
solutin (and I will clarufy immidatley why) but it works...

example:

.cpp.o:
      temp.bat << temp.bat
@echo off
prog1.exe $@
gcc.exe $@ -DVAR=%ERRORLEVEL% -o $<.exe
<<NOKEEP

and why this solution is not clean? It will cleanly create the file temp.bat
on disk and will erase it after wards. The only problem is that it will not
run "temp.bat" but "temp.bat temp.bat", which prevents you from using the
parameters (%1, %2....) or temp.bat inside it.

But that's what I have :)

Hope it helps,
Boaz

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.