Re: DOS program recording it's parameters and environment?

Frantisek Hanzlik <[email protected]>
Newsgroups org.kernel.vger.linux-msdos
Message-ID <[email protected]>
Paul Crawford napsal(a):
> Dear Frantisek,
>> Excuse me for slightly OT question. Know anyone DOS program, which is
>> able record infos with what parameters was started and eventually
>> other informations about calling environment (e.g. environment
>> variables, available memory etc.)?
> 
> Attacked is a gzip'd tar file with a simple program to do this, but
> re-named .dat instead of .tgz as we use Google mail and it is too stupid
> to allow compressed executables to be emailed.
> 
> Save to a Linux box and then re-name, then the usual arcive manager or
> tar can extract the files.
> 
> It creates a file dosenv.txt in the working directory and prints out the
> calling arguments and the environment to that file. If you have a C
> compiler (I used Microsoft's C6.0 DOS compiler from around 1988) you
> could modify this program to do other things (e.g. date/time based file
> names if they fit the 8.3 limit of DOS, etc)
> 
> Regards,
> Paul

Hello Paul,

many thanks for Your help. I have not bigger piece of time for playing
with until yesterday. And I must say You program work well, is quite
tiny and when I have seen how it is simple, I was ashamed for being so
powerless for writing similar code.

I was trying slightly modify You code (nothing much, only write result
to not fixed name file, but to filename basename(argv[0]) and open it
for append and write there timestamp when program run). Because I have
not had any C compiler before, I was downloading and using OpenWatcom C
compiler v1.9 (http://www.openwatcom.org/) for DOS. And there I knock
to problem - it seems as this compiler not support construction:

int main(int argc, char *argv[], char *envp[])

in the concrete, pointer to environment vector perhaps isn't possible or
valid. Program compiles and links fine, run without problems, printed
args are OK, but instead of environment variables it output only several
weird characters. Thus, when I can still ask, know You or someone in
DOSEMU or FreeDOS forum:

- when is possible walk through environment values in Watcom C?
I think it may be possible with some undocumented functions, with some
included assembler code etc. Or there may be problem e.g. in incorrect
variable alignment in memory...? ;)

- or when there is other free DOS C compiler which would be possible use?

Thanks in advance, Franta Hanzlik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.