activeperl + -T option

Discussion in 'Perl Misc' started by Robin, Apr 20, 2004.

  1. Robin

    Robin Guest

    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 ]
     
    Robin, Apr 20, 2004
    #1
    1. Advertising

  2. Robin

    Clyde Ingram Guest

    Robin,

    "Robin" <robin @ infusedlight.net> wrote in message
    news:c62hsr$qci$...
    > 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
     
    Clyde Ingram, Apr 20, 2004
    #2
    1. Advertising

  3. 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
     
    Tassilo v. Parseval, Apr 20, 2004
    #3
  4. Robin

    Robin Guest

    > "Robin" <robin @ infusedlight.net> wrote in message
    > news:c62hsr$qci$...
    > > 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 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 ]
     
    Robin, Apr 20, 2004
    #4
  5. Robin

    Robin Guest

    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, Apr 20, 2004
    #5
  6. Robin

    Robin Guest

    "Clyde Ingram"
    <> wrote
    in message news:9o7hc.52$...
    > Robin,
    >
    > "Robin" <robin @ infusedlight.net> wrote in message
    > news:c62hsr$qci$...
    > > 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_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
     
    Robin, Apr 21, 2004
    #6
  7. Robin

    Robin Guest

    "Tassilo v. Parseval" <> wrote in message
    news:c6304s$7edtm$-berlin.de...
    > 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

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

    -Robin
     
    Robin, Apr 21, 2004
    #7
  8. 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
     
    Tassilo v. Parseval, Apr 21, 2004
    #8
  9. Robin

    Joe Smith Guest

    Robin wrote:

    > "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
     
    Joe Smith, Apr 21, 2004
    #9
  10. "Robin" <robin @ infusedlight.net> wrote in message
    news:c63mu9$6fe$...
    > > "Robin" <robin @ infusedlight.net> wrote in message
    > > news:c62hsr$qci$...
    > > > 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 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.
    >

    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
     
    Brian Helterline, Apr 22, 2004
    #10
  11. Robin

    Robin Guest


    > 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
     
    Robin, Apr 24, 2004
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julien ROUZIERES

    g++ -pg option and -shared option

    Julien ROUZIERES, Dec 21, 2004, in forum: C++
    Replies:
    1
    Views:
    736
    GianGuz
    Dec 21, 2004
  2. Cas
    Replies:
    5
    Views:
    807
    Kevin Jones
    Aug 28, 2006
  3. Kevin Blount

    page.aspx?option - how to detect "option"

    Kevin Blount, Nov 28, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    615
    =?Utf-8?B?RWVyYWo=?=
    Nov 28, 2006
  4. Viviana Vc

    ActivePerl and -P option

    Viviana Vc, Jun 3, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    115
    Viviana Vc
    Jun 8, 2005
  5. Ted
    Replies:
    7
    Views:
    580
    Sisyphus
    Dec 16, 2006
Loading...

Share This Page