tags:

views:

475

answers:

3

I have a COBOL exe program which calls a COBOL dll which in turn calls a COBOL program using a dos interrupt 'x91 - the calling program uses an 'x91' to activate an EXE file as if it were typed in as an operating system command line entry. The security program which wraps my cobol code is a third party program which wraps around my program. The author has suggested that my program read environment variables to insure that the security has not been hacked. I have been unable to get my cobol to read the variables, so I thought that writing the program in C, the variables could be read. All the present program does is create a small sequential file, write one record to it and close the file - for security, I have the program wrapped by third party security software, and it generates the variables I want to verify to allow the progam to write the record weith the contents of the security check as passed or not passed. the calling program (a cobol dll) then tests for the presence of the file, reads the record and validates whether the code for security has been written into the file.

The COBOL program needs to be translated to C++ because the author of the security wrapping code says he can't interface with cobol executables.

  • The present program is small
  • All it does is create a small sequential flat text file, write one record to it, and then write the record and close the file.
  • The program needs to check for the presence and value of certain "environment" variables being generated by a security program which wraps around the little program generating the file, and runs while the wrapped program is running.

For example, the variable "LICENSE" Returns the name of the current license used. thanks for any input.

The author of the security software has been unable to provide a small executable to check his variables, so I am looking to create one from scratch which will emulate the little cobol program I have been referring to (read the environment variables of the security program wrapping and securing my little program, create a file, write one record to it, the contents of which depend on the environment variable's values, and then close the file). In this way, the calling DLL will receive the file written by the small program executed by 'x91' call to the operating system (the one which needs to be coded in C++ instead of the present Cobol), verify its contents, and either allow the main program to procede or not. The main software consists of over 500 programs which I have ported from mainframe legacy code to PC. I used to use dongles but my clients hated them as they interferred with their printers...

the DOS call which activates the new little wrapped program will work with any executable program so it really is not an issue..

+1  A: 

Some points:

  • I really don't think your code is being executed by a "DOS interrupt" as you can't use those with Windows, which your question implies you are using. BTW, please add SO tags to indicate this.
  • You say that it can't read environment variables, but that the calling application (written in the same language) can create them? This doesn't seem likely either.
  • Where in the code do you want to read the environment variable & what do you want to with it?

As a quick solution, I suggest having the wrapping code write the environment variable values out to a file and then read that. If you really want a C or C++ solution, you will have to clarify your question.

Edit: Please note that StackOverflow is a site for answering programming questions - it is not a site to provide you with free software. If the problem is as easy as you say it is (and requires a C solution, something I am still not convinced of), hire a C programmer for half a day to write it.

anon
+1  A: 

As we don't all speak COBOL here, and that the code is reasonably small, it will probably be in your best interests to write some pseudo-code that explains what the COBOL does.

I could probably find a one-liner in Perl that'd do exactly what you want, but at present, I don't know exactly what you do want, so I can't help you.( Even if you did want a Perl-one-liner ;) )

Kent Fredric
+2  A: 

I know nothing about COBOL, but there are pretty clear instructions for using it to read Windows environment variables here.

After looking over that, I am glad I don't know anything about COBOL.

JosephStyons
it would appear, after somebody else explained it to me, the snippet of code he posted earlier was ~= echo "a10charstring" > file
Kent Fredric