Home > Archive > PERL Miscellaneous > April 2004 > activeperl + -T option
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
activeperl + -T option
|
|
|
| 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.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
| |
| Clyde Ingram 2004-04-20, 7:39 am |
| Robin,
"Robin" <robin @ infusedlight.net> wrote in message
news:c62hsr$qci$1@reader2.nmix.net...
> 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 est 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
| |
| Tassilo v. Parseval 2004-04-20, 7:39 am |
| 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
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
| |
|
| > "Robin" <robin @ infusedlight.net> wrote in message
> news:c62hsr$qci$1@reader2.nmix.net...
turn[color=darkred]
> script
> whenever
>
> 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[color=darkred]
> be
Do[color=darkred]
> I
there[color=darkred]
[color=darkred]
>
> 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.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
| |
|
| 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.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
| |
| Robin 2004-04-20, 10:30 pm |
|
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:c6304s$7edtm$1@ID-231055.news.uni-berlin.de...
> Also sprach Robin:
>
turn[color=darkred]
script[color=darkred]
whenever[color=darkred]
to be[color=darkred]
Do I[color=darkred]
there[color=darkred]
>
> 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
> --
>
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
>
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
>
$_=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
| |
| Robin 2004-04-20, 10:30 pm |
|
"Clyde Ingram"
< clydenospamorham@nospamorhamgetoffthelin
e.freeservenospamorham.co.uk> wrote
in message news:9o7hc.52$pl4.33@newsfe3-win.server.ntli.net...
> Robin,
>
> "Robin" <robin @ infusedlight.net> wrote in message
> news:c62hsr$qci$1@reader2.nmix.net...
turn[color=darkred]
> script
> whenever
>
> 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[color=darkred]
> be
Do[color=darkred]
> I
there[color=darkred]
>
> 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 est 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 , it's still
running. Check out new scripts at www.infusedlight.net
-Later,
Robin
| |
| Tassilo v. Parseval 2004-04-21, 3:32 am |
| 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
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
| |
| Joe Smith 2004-04-21, 6:32 am |
| Robin wrote:
> "Clyde Ingram"
> ... [over 100 lines deleted]
> Yeah, optiperl still isn't working with this, but it's , 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
| |
| Brian Helterline 2004-04-22, 3:46 pm |
|
"Robin" <robin @ infusedlight.net> wrote in message
news:c63mu9$6fe$1@reader2.nmix.net...
> turn
>
> to
I've[color=darkred]
> Do
> there
>
>
> with
>
> 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.
--
brian
| |
| Robin 2004-04-28, 10:46 am |
|
> 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.
>
> --
> brian
good call! I hadn't thought of that at all.
-Robin
|
|
|
|
|