# Why doesn't cl.exe generate any output when I call it from Perl?

I'm having a weird problem with running cl.exe that has me stumped. In a large VS2008 solution consisting of C/C++ projects, I have one project that runs some scripts to do some extra processing. The project consists of a pre-build event, which calls a Perl script (ActiveState Perl is on the machine). This Perl script then calls cl.exe with /E to generate preprocessed output which gets redirected to a file. The line in Perl looks like this:

my \$foo = "\path\to\cl.exe" @args.rsp >out.txt 2>err.txt;


args.rsp is a plain text file that contains a bunch of command line args for cl.exe, including /E to get pre-processor output on stdout.

This exact command line works as expected when run from the VS2008 command prompt. Building the project also works fine on my Windows XP machine. However, on my new Windows 7 box, when I build the project, out.txt ends up blank. I should also add that on some of my coworker's Windows 7 boxes, it works fine, and on some others it doesn't.

Clearly there's some kind of configuration difference going on, but I'm at a loss as to what it may be. We've checked matching versions of VS2008 SP1 and ActiveState Perl. I've tried myriad workarounds within the perl script - using system() instead of backticks, using cl.exe /P to output to a file and then moving the file (the file is blank), unsetting the VS_UNICODE_OUTPUT environment variable (no effect). Nothing has changed the behavior - output is generated when the command line is run manually, but not when it's run inside the pre-build event for this project.

Any ideas on what kind of configuration problem may be causing this? I'm pretty much out of avenues to pursue.

Sounds like an ACL issue to me. You can change windows to log access issues and then check the event log to see what user is getting access denied errors.

I believe the setting is in Local Policy | Audit Policy | Audit Object Access

Check out the exit code of your program. You may want to build your executable name in a portable way using something like File::Spec. Also, check that @args is not interpolating. You may want to print your command line before executing to check if that's what you want. What is left your err.txt file?