activeperl + -T option

R

Robin

I am running active perl 8.2.3 Build 809 and I'm wondering why when I turn
on taint mode checking on the #!/usr/bin/perl line whenver I run the script
it gives me an error "Too late for -T option at bbs.pl line 1." and whenever
I run the script with perl -T bbs.pl it works fine....is there any
configuration file I can edit so perl will automatically understand it to be
run with a -T option? I want to run the script with a Perl IDE that I've
downloaded and it gives me this error unless I take out the -T option. Do I
have to take out the -T evertime I run the script with the IDE or is there
something I can do?
Thanks in advance.
 
C

Clyde Ingram

Robin,

Robin said:
I am running active perl 8.2.3 Build 809 and I'm wondering why when I turn
on taint mode checking on the #!/usr/bin/perl line whenver I run the script
it gives me an error "Too late for -T option at bbs.pl line 1." and whenever
I run the script with perl -T bbs.pl it works fine

You have not said which platform you are running on.
What you hint at should behave correctly on most UNIX systems.
There are several well documented bugs in how DROSS and Windoze systems
invoke Perl programs . . .
....is there any
configuration file I can edit so perl will automatically understand it to be
run with a -T option? I want to run the script with a Perl IDE that I've
downloaded and it gives me this error unless I take out the -T option. Do I
have to take out the -T evertime I run the script with the IDE or is there
something I can do?

I assume Windoze.

From the ActivePerl user guide, look at
file://E:\Perl\html\faq\Windows\ActivePerl-Winfaq4.html#What_s_the_equivalent_of_the_she
(for E:, substitute the drive you have installed ActivePerl on):
<QUOTE>Unfortunately, Win32 platforms don't provide the shebang syntax, or
anything like it. You can try one of the two following methods to run a
script from the command line. If all else fails, you can always just call
the perl interpreter directly, as in perl myscript.pl.

.. . .

For Windows NT 4.0/2000, the coolest method is to use associated file types
(see How do I associate Perl scripts with perl?). If you've associated Perl
scripts with the .pl extension, you can just type the name of your file at
the command line and Windows NT/2000 will launch perl.exe for you.

</QUOTE>

I guess you could hard-wire "-T" into the Perl command line associated with
extension ".pl", but that would impose taint checking everywhere, which
would give you headaches.



If you change the PATHEXT environment variable to include .pl files, like
this:

SET PATHEXT=.pl;%PATHEXT%
you can just type the file name without an extension, and Windows NT/2000
will find the first .pl file in your path with that name. You may want to
set PATHEXT in the System control panel rather than on the command line.
Otherwise, you'll have to re-enter it each time the command prompt window
closes.

<QUOTE> Note that the file association method does not work for Windows 9x,
nor does it work with Windows NT/2000 if you have command extensions
disabled. You can, however, still start the Perl script from an Explorer
window if the extension is associated with perl.

Another option is to use the pl2bat utility distributed with ActivePerl to
convert your Perl script into a batch file. What this does is tag some Win32
batch language to the front of your script so that the system calls the perl
interpreter on the file. It's quite a clever piece of batch coding,
actually.

If you call the pl2bat utility on your Perl script helloworld.pl, like this:

C:\> pl2bat helloworld.pl
it will produce a batch file, helloworld.bat. You can then invoke the script
just like this:

C:\> helloworld
Hello, World!
You can pass command line parameters, as well. Your script can be in your
PATH, or in another directory, and the pl2bat code will usually find it and
execute it correctly. The big advantage of this over file associations is
that I/O redirection will work correctly.

pl2bat has a number of useful command line options to affect how the
wrapping is done, what command line switches to pass to perl, etc. Running
perldoc pl2bat at the command line will show a full description of these
options.

</QUOTE>

When I run this little script, called "trial_shebang.pl":
#!e:\perl\bin\perl.exe -wT

use strict;
print "Howdy do there\n"

I see what you saw:
D:\Clyde\perldev\Trial>trial_shebang.pl
Too late for "-T" option at D:\Clyde\perldev\Trial\trial_shebang.pl
line 1.

When I run:
D:\Clyde\perldev\Trial>pl2bat trial_shebang.pl

pl2bat creates a DROSS batch file "trial_shebang.bat"
When I run it, I see this:

D:\Clyde\perldev\Trial>trial_shebang
Howdy do there

Now, whether this is any help to you depends on how your IDE invokes your
Perl programs.
Which IDE was it?
..
Regards,
Clyde
 
T

Tassilo v. Parseval

Also sprach Robin:
I am running active perl 8.2.3 Build 809 and I'm wondering why when I turn
on taint mode checking on the #!/usr/bin/perl line whenver I run the script
it gives me an error "Too late for -T option at bbs.pl line 1." and whenever
I run the script with perl -T bbs.pl it works fine....is there any
configuration file I can edit so perl will automatically understand it to be
run with a -T option? I want to run the script with a Perl IDE that I've
downloaded and it gives me this error unless I take out the -T option. Do I
have to take out the -T evertime I run the script with the IDE or is there
something I can do?

The reason why this happens is that your operating system (most probably
Windows) doesn't take the shebang line into account. However, perl does.
It executes the script and looks at the shebang line to see whether it
should include some switches (like -w). This doesn't work with the -T
switch because a perl instance cannot switch to tainted mode. It has to
know right from the start that it should use taintedness.

You can probably tell your IDE to use 'perl -T' instead of 'perl' as the
interpreter.

Tassilo
 
R

Robin

Robin said:
You have not said which platform you are running on.
What you hint at should behave correctly on most UNIX systems.
There are several well documented bugs in how DROSS and Windoze systems
invoke Perl programs . . . to Do


I guess you could hard-wire "-T" into the Perl command line associated with
extension ".pl", but that would impose taint checking everywhere, which
would give you headaches.

I was thinking the exact same thing...thanks.
If you change the PATHEXT environment variable to include .pl files, like
this:

SET PATHEXT=.pl;%PATHEXT%
you can just type the file name without an extension, and Windows NT/2000
will find the first .pl file in your path with that name. You may want to
set PATHEXT in the System control panel rather than on the command line.
Otherwise, you'll have to re-enter it each time the command prompt window
closes.

Thanks... this is probably what I'll do. I mainly write cgi scripts, so
having -T imposed on all my scripts won't be too bad.

Which IDE was it?

Optiperl. And it doesn't have an option for turning on taint checking.
 
R

Robin

Thanks...
You can probably tell your IDE to use 'perl -T' instead of 'perl' as the
interpreter.

This is the problem...I can't...but I'll probably do what Clyde suggested.
Thanks.
 
R

Robin

"Clyde Ingram"
Robin,



You have not said which platform you are running on.
What you hint at should behave correctly on most UNIX systems.
There are several well documented bugs in how DROSS and Windoze systems
invoke Perl programs . . .
to Do

I assume Windoze.

From the ActivePerl user guide, look at
file://E:\Perl\html\faq\Windows\ActivePerl-Winfaq4.html#What_s_the_equivalen
t_of_the_she
(for E:, substitute the drive you have installed ActivePerl on):
<QUOTE>Unfortunately, Win32 platforms don't provide the shebang syntax, or
anything like it. You can try one of the two following methods to run a
script from the command line. If all else fails, you can always just call
the perl interpreter directly, as in perl myscript.pl.

. . .

For Windows NT 4.0/2000, the coolest method is to use associated file types
(see How do I associate Perl scripts with perl?). If you've associated Perl
scripts with the .pl extension, you can just type the name of your file at
the command line and Windows NT/2000 will launch perl.exe for you.

</QUOTE>

I guess you could hard-wire "-T" into the Perl command line associated with
extension ".pl", but that would impose taint checking everywhere, which
would give you headaches.



If you change the PATHEXT environment variable to include .pl files, like
this:

SET PATHEXT=.pl;%PATHEXT%
you can just type the file name without an extension, and Windows NT/2000
will find the first .pl file in your path with that name. You may want to
set PATHEXT in the System control panel rather than on the command line.
Otherwise, you'll have to re-enter it each time the command prompt window
closes.

<QUOTE> Note that the file association method does not work for Windows 9x,
nor does it work with Windows NT/2000 if you have command extensions
disabled. You can, however, still start the Perl script from an Explorer
window if the extension is associated with perl.

Another option is to use the pl2bat utility distributed with ActivePerl to
convert your Perl script into a batch file. What this does is tag some Win32
batch language to the front of your script so that the system calls the perl
interpreter on the file. It's quite a clever piece of batch coding,
actually.

If you call the pl2bat utility on your Perl script helloworld.pl, like this:

C:\> pl2bat helloworld.pl
it will produce a batch file, helloworld.bat. You can then invoke the script
just like this:

C:\> helloworld
Hello, World!
You can pass command line parameters, as well. Your script can be in your
PATH, or in another directory, and the pl2bat code will usually find it and
execute it correctly. The big advantage of this over file associations is
that I/O redirection will work correctly.

pl2bat has a number of useful command line options to affect how the
wrapping is done, what command line switches to pass to perl, etc. Running
perldoc pl2bat at the command line will show a full description of these
options.

</QUOTE>

When I run this little script, called "trial_shebang.pl":
#!e:\perl\bin\perl.exe -wT

use strict;
print "Howdy do there\n"

I see what you saw:
D:\Clyde\perldev\Trial>trial_shebang.pl
Too late for "-T" option at D:\Clyde\perldev\Trial\trial_shebang.pl
line 1.

When I run:
D:\Clyde\perldev\Trial>pl2bat trial_shebang.pl

pl2bat creates a DROSS batch file "trial_shebang.bat"
When I run it, I see this:

D:\Clyde\perldev\Trial>trial_shebang
Howdy do there

Now, whether this is any help to you depends on how your IDE invokes your
Perl programs.
Which IDE was it?
.
Regards,
Clyde

Yeah, optiperl still isn't working with this, but it's cool, it's still
running. Check out new scripts at www.infusedlight.net
-Later,
Robin
 
R

Robin

Tassilo v. Parseval said:
Also sprach Robin:


The reason why this happens is that your operating system (most probably
Windows) doesn't take the shebang line into account. However, perl does.
It executes the script and looks at the shebang line to see whether it
should include some switches (like -w). This doesn't work with the -T
switch because a perl instance cannot switch to tainted mode. It has to
know right from the start that it should use taintedness.

You can probably tell your IDE to use 'perl -T' instead of 'perl' as the
interpreter.

Tassilo
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
[/QUOTE]
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

So Perl's not that smart... I'm so burned out on perl, what's perl.

-Robin
 
T

Tassilo v. Parseval

Also sprach Robin:
So Perl's not that smart... I'm so burned out on perl, what's perl.

perl is the thing which runs programs written in Perl. See

What's the difference between "perl" and "Perl"?

in perlfaq1.

Other than that, the tainting-happening-too-late issue is none of the
language. It's about the interpreter being not smart enough to do it.
However, tainted mode hooks very deeply into the interpreter and it is
not trivial to switch from untainted to tainted mode at runtime. It may
look trivial to you but taintedness has some serious implications for
the whole interpreter in nearly all aspects.

That's why the interpreter has to be told about it right at the start.

Tassilo
 
J

Joe Smith

Robin said:
"Clyde Ingram"
... [over 100 lines deleted]
Yeah, optiperl still isn't working with this, but it's cool, it's still
running. Check out new scripts at www.infusedlight.net

Don't quote the entire article just to add two lines of commentary.
-Joe
 
B

Brian Helterline

Robin said:
I was thinking the exact same thing...thanks.
Another solution is to have your CGI scripts end with .cgi rather than .pl
and then create the association of .cgi to perl with -T enabled. This
forces all cgi scripts to be run with -T while normal perl scripts (.pl) are
not.
 
R

Robin

Another solution is to have your CGI scripts end with .cgi rather than .pl
and then create the association of .cgi to perl with -T enabled. This
forces all cgi scripts to be run with -T while normal perl scripts (.pl) are
not.

good call! I hadn't thought of that at all.
-Robin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top