Invoking TCC FROM Perl 5.12

Jun 4, 2008
30
0
I want to execute a "dir /bf" command from within Perl. As the "f" option is a TCC option I need to invoke TCC.EXE instead of CMD.EXE. To do this I create the environment variable:
PERL5SHELL=C:\Program Files\JPSoft\TCMD12x64\tcc.exe
and then run the program:

#!perl -w
use strict;
use 5.12.0;

say $ENV{PERL5SHELL};
my @lns=`dir /bf `;
die $! if ($!);
chomp @lns;
say $_ foreach @lns;

When I do this I get the output:

C:\Program Files\JPSoft\TCMD12x64\tcc.exe
Bad file descriptor at C:\TestPad\debgtest.pl line 7.

If I do not create the PERL5SHELL then cmd.exe is invoked and the command work as expected (After I change the command to `dir /b` ).

Am I doing anything obviously wrong here or is TCC simply different from cmd.exe in a way that perl can not capture the command output stream as expected?

I am running
TCC 12.01.44 x64 Windows 7 [Version 6.1.7600]

and ActiveState Perl 5.12.2
 
Jun 2, 2008
38
0
Denmark
I want to execute a "dir /bf" command from within Perl. As the "f" option is a TCC option I need to invoke TCC.EXE instead of CMD.EXE. To do this I create the environment variable:
PERL5SHELL=C:\Program Files\JPSoft\TCMD12x64\tcc.exe
and then run the program:

etc. etc.

This command works in cmd.exe:

tcc.exe /c dir /bf​

Its output can be piped so I'd assume that it works with your perl program
 
Jun 4, 2008
30
0
This command works in cmd.exe:
tcc.exe /c dir /bf​
Its output can be piped so I'd assume that it works with your perl program

You are right. I can remove the PERL5LIB environment variable and then use the line:

my @lns=`tcc /c dir /bf `;

and get the expected directory listing. The down side is
1) each call results in two command shells are invoked: cmd.exe and tcc.exe.
2) The current working directory is not passed on through to tcc

It would seem that either:
1) perl is incorrectly invoking tcc or is not hooking up the output pipe correctly. Perl does hook up to cmd correctly and cmd correctly captures the output from tcc and thus passes it back to perl.
or
2) tcc is not emulating cmd.exe exactly

or I suppose, both.

In any case thanks for the solution. I hadn't thought of invoking tcc from cmd.exe

David
 
May 20, 2008
3,515
4
Elkridge, MD, USA
---- Original Message ----
From: David McClelland
To: ESFabian@zenge.org
Sent: Friday, 2011. February 11. 16:24
Subject: RE: [Support-t-2604] Re: Invoking TCC FROM Perl 5.12

| Quote:
| Originally Posted by ebbe
| This command works in cmd.exe:
| tcc.exe /c dir /bf
| Its output can be piped so I'd assume that it works with your perl
| program
|
| You are right. I can remove the PERL5LIB environment variable and
| then use the line:
|
| my @lns=`tcc /c dir /bf `;
|
| and get the expected directory listing. The down side is
| 1) each call results in two command shells are invoked: cmd.exe and
| tcc.exe.
| 2) The current working directory is not passed on through to tcc
|
| It would seem that either:
| 1) perl is incorrectly invoking tcc or is not hooking up the output
| pipe correctly. Perl does hook up to cmd correctly and cmd correctly
| captures the output from tcc and thus passes it back to perl.
| or
| 2) tcc is not emulating cmd.exe exactly
|
| or I suppose, both.
|
| In any case thanks for the solution. I hadn't thought of invoking tcc
| from cmd.exe

Try to insert the current directory into the command invoking TCC (without knowledge of Perl I symbolically represented it below as "cwd"):
my @lns=`tcc /c dir /bf cwd`;

As to invoking TCC without passing through CMD.EXE, try the same Perl command format that would invoke any other program (esp. text mode one, not a graphics mode one), most likely requiring the full path of TCC.EXE in the command.
--
Steve
 
Similar threads
Thread starter Title Forum Replies Date
S WAD Invoking BDEBUGGER changes window title to "TCC Prompt" Support 7
Phileosophos LIST edit not invoking my specified editor Support 4
Steve Pitts Documentation Script errors invoking help Support 15
S Installing on Win 7 without invoking UAC Support 2
M Invoking a DOS command within a C++ program Support 1
MickeyF TCC crashing when copying multiple files (now resolved) Support 6
C COMSPEC constantly reset to TCC.EXE Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
L FTYPE in TCC, less quirky than in cmd.exe Support 3
V Set path permanently from within TCC? Support 3
DrusTheAxe Runaway TCC.exception.log filling drive Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
Joe Caverly tcc.exception.log Support 3
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
vefatica SCRIPT ... TCC disappears Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
Jesse Heines Access Denied errors in TCC 27 Support 9
fpefpe How to? tcc inifile (%_ininame) Support 3
M How to? Black TCC Prompt Support 2
D Differences between TCC and CMD with COPY /b Support 4
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
Jay Sage Extra TCC Tasks Support 6
vefatica Can I turn off the minimize to tray mechanism in TCC? Support 5
N Command execution slows down in TCC Prompt after a while Support 6
R Upgrade TCMD 19 to TCC 26 Support 1
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
samintz How to? Is this doable in TCC? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0
D TCC tab detaching & restarting Support 3
Ó Recent git output not shown on TCC Support 1
P Kill all other instances of tcc from a btm batch file Support 2
L Using TCC.exe through an SSH connection Support 3
M TCC color issue in ConEmu Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
Alpengreis Python support for 3.8.3 in TCC v26.x? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.01.40 uploaded Support 0
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.37 Uploaded Support 0
vefatica TCC waits for Office apps Support 4
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
M Strange error messages from TCC in FTP copy Support 7
Kachupp Documentation tcc-rt versions Support 1

Similar threads