need simple beep and taint mode

Discussion in 'Perl Misc' started by Yohan N. Leder, Jul 2, 2006.

  1. Very quick question this time. How to do a 'print "\a";' still produces
    a beep when script is in taint mode. It works fine without -T, but
    nothing in speaker when I'm back to taint mode. If it has some
    importance, this test has been done using ActivePerl 5.8.8.817 under Win
    2K. What's the trick ?
    Yohan N. Leder, Jul 2, 2006
    #1
    1. Advertising

  2. Yohan N. Leder <> writes:

    > Very quick question this time. How to do a 'print "\a";' still produces
    > a beep when script is in taint mode. It works fine without -T, but
    > nothing in speaker when I'm back to taint mode. If it has some
    > importance, this test has been done using ActivePerl 5.8.8.817 under Win
    > 2K. What's the trick ?


    How are you running your tests? Perl doesn't actually beep; 'print "\a";'
    simply sends an ASCII control character to stdout. It's up to whatever's
    collecting your script's output to decide how to respond to that character.

    Quite a few terminals, for instance, have an option to invert the display
    colors briefly instead of (or in addition to) beeping, for the hearing-
    impaired.

    So, are you running both tests in the same shell? Or does the silent one
    happen to be running under something that's not likely to beep in response
    to a "\a", such as a web server?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Jul 2, 2006
    #2
    1. Advertising

  3. Yohan N. Leder

    -berlin.de Guest

    Yohan N. Leder <> wrote in comp.lang.perl.misc:
    > Very quick question this time.


    If you don't know the answer, how do you know it's a "quick question"?

    > How to do a 'print "\a";' still produces
    > a beep when script is in taint mode. It works fine without -T, but
    > nothing in speaker when I'm back to taint mode. If it has some
    > importance, this test has been done using ActivePerl 5.8.8.817 under Win
    > 2K. What's the trick ?


    I can't reproduce your findings. If your diagnosis is indeed correct,
    this looks like a rather messy problem.

    Anno
    -berlin.de, Jul 3, 2006
    #3
  4. Yohan N. Leder wrote:

    > Very quick question this time. How to do a 'print "\a";' still produces
    > a beep when script is in taint mode. It works fine without -T, but
    > nothing in speaker when I'm back to taint mode. If it has some
    > importance, this test has been done using ActivePerl 5.8.8.817 under Win
    > 2K.


    Yes - I get a beep too under WinXP ActivePerl 5.8.4. This same beep can
    be achieved by e.g. typing "echo", space, control-G and then Enter.
    This should work in most/all terminals, as CTRL-G corresponds to
    dec/hex 07 (BEL, bell, 0000111 in 7-bit ASCII) as the de-facto bell
    signal.

    The same would probably happen when displaying binaries in your
    terminal, something like:

    open my $F, '<', 'image.gif' || die "Cant open: $!";
    print while(<$F>);
    close $F || die "Cant close: $!";

    My conclusion:
    You can't know at Perl level whether or not the terminal will beep at
    any character. It's just up to the shell. I would say this hasn't any
    real importance too. Unless you want to program a singing shell or so
    :)

    Hope this helps,

    --
    Bart
    Bart Van der Donck, Jul 3, 2006
    #4
  5. Sherm Pendley wrote:

    > [...]
    > Perl doesn't actually beep; 'print "\a";' simply sends an ASCII control
    > character to stdout. It's up to whatever's collecting your script's output
    > to decide how to respond to that character.
    > [...]


    Then you're actually saying that \a would be an alias to hex/dec 7 on
    Yohan's terminal, because no other ASCII control character seems to
    produce a beep on DOS-ish terminals:

    #!perl

    print "char $_ is ",chr($_),"\n" for (0..31);

    =for nobody
    ASCII CONTROL CHARACTERS
    Dec Hex ASCII KEY
    0 00 NUL (null) Ctrl-@
    1 01 SOH (start of heading) Ctrl-A
    2 02 STX (start of text) Ctrl-B
    3 03 ETX (end of text) Ctrl-C
    4 04 EOT (end of transmission) Ctrl-D
    5 05 ENQ (enquiry) Ctrl-E
    6 06 ACK (acknowledge) Ctrl-F
    7 07 BEL (bell) Ctrl-G
    8 08 BS (backspace) Ctrl-H
    9 09 HT (horizontal tab) Ctrl-I
    10 0A LF (line feed) Ctrl-J
    11 0B VT (vertical tab) Ctrl-K
    12 0C FF (form feed) Ctrl-L
    13 0D CR (carriage return) Ctrl-M
    14 0E SO (shift out) Ctrl-N
    15 0F SI (shift in) Ctrl-O
    16 10 DLE (data link escape) Ctrl-P
    17 11 DC1 (device control 1) Ctrl-Q
    18 12 DC2 (device control 2) Ctrl-R
    19 13 DC3 (device control 3) Ctrl-S
    20 14 DC4 (device control 4) Ctrl-T
    21 15 NAK (negative acknowledge) Ctrl-U
    22 16 SYN (synchronous idle) Ctrl-V
    23 17 ETB (end of trans. block) Ctrl-W
    24 18 CAN (cancel) Ctrl-X
    25 19 EM (end of medium) Ctrl-Y
    26 1A SUB (substitute) Ctrl-Z
    27 1B ESC (escape) Ctrl-[
    28 1C FS (file separator) Ctrl-\
    29 1D GS (group separator) Ctrl-]
    30 1E RS (record separator) Ctrl-^
    31 1F US (unit separator) Ctrl-_
    =cut

    __END__

    Maybe \a might be considered short for 'alarm' or 'alert'...

    I might be wrong about this, but I rather think that \a doesn't refer
    to an ASCII control character, but to a "somewhere far higher"
    character. The fact that \a corresponds to a beep on some shells,
    doesn't necessarily imply a relation to Hex 07.

    --
    Bart
    Bart Van der Donck, Jul 3, 2006
    #5
  6. Yohan N. Leder

    -berlin.de Guest

    Bart Van der Donck <> wrote in comp.lang.perl.misc:
    > Sherm Pendley wrote:
    >
    > > [...]
    > > Perl doesn't actually beep; 'print "\a";' simply sends an ASCII control
    > > character to stdout. It's up to whatever's collecting your script's output
    > > to decide how to respond to that character.
    > > [...]

    >
    > Then you're actually saying that \a would be an alias to hex/dec 7 on
    > Yohan's terminal, because no other ASCII control character seems to
    > produce a beep on DOS-ish terminals:


    That is exactly what he's saying, and it's true too.

    [snip]

    > Maybe \a might be considered short for 'alarm' or 'alert'...


    Perl calls it "alarm (bell)" (see perlop). It's a backslash escape
    like "\n" and many more.

    > I might be wrong about this,


    You are, unnecessarily.

    > but I rather think that \a doesn't refer
    > to an ASCII control character, but to a "somewhere far higher"
    > character. The fact that \a corresponds to a beep on some shells,
    > doesn't necessarily imply a relation to Hex 07.


    No seed to guess:

    print "okay\n" if "\a" eq "\cG" and "\a" eq chr 7;

    prints okay and removes all doubt.

    Anno
    -berlin.de, Jul 3, 2006
    #6
  7. -berlin.de wrote:

    > Bart Van der Donck <> wrote in comp.lang.perl.misc:
    > > [...]
    > > but I rather think that \a doesn't refer
    > > to an ASCII control character, but to a "somewhere far higher"
    > > character. The fact that \a corresponds to a beep on some shells,
    > > doesn't necessarily imply a relation to Hex 07.

    >
    > No seed to guess:
    >
    > print "okay\n" if "\a" eq "\cG" and "\a" eq chr 7;
    >
    > prints okay and removes all doubt.


    It does. I see.

    --
    Bart
    Bart Van der Donck, Jul 3, 2006
    #7
  8. In article <>, sherm@Sherm-
    Pendleys-Computer.local says...
    > Yohan N. Leder <> writes:
    >
    > > Very quick question this time. How to do a 'print "\a";' still produces
    > > a beep when script is in taint mode. It works fine without -T, but
    > > nothing in speaker when I'm back to taint mode. If it has some
    > > importance, this test has been done using ActivePerl 5.8.8.817 under Win
    > > 2K. What's the trick ?

    >
    > How are you running your tests? Perl doesn't actually beep; 'print "\a";'
    > simply sends an ASCII control character to stdout. It's up to whatever's
    > collecting your script's output to decide how to respond to that character.
    >
    > Quite a few terminals, for instance, have an option to invert the display
    > colors briefly instead of (or in addition to) beeping, for the hearing-
    > impaired.
    >
    > So, are you running both tests in the same shell? Or does the silent one
    > happen to be running under something that's not likely to beep in response
    > to a "\a", such as a web server?
    >
    > sherm--
    >
    >


    My test has been done in a DOS box under Win2K, running "perl beep.pl"
    with beep.pl being :

    #!/usr/bin/perl -w
    use strict;
    $|=1;
    print "\a";
    exit 0;

    However, since I ran this script through a Win32::process::Create call,
    I didn't seen that when "#!/usr/bin/perl -wT", it gives an error message
    ('-T is on the #! line, it must also be used on the command line at
    beep.pl line 1') which does 'print "\a";' is never reached. So, running
    "perl -T beep.pl" resolve the thing and beep is heard.

    Nevertheless, because you talk about CGI orientation, it interest me too
    to know how to produce a simple beep in internal speaker when script is
    reached through web server and current STDOUT is a web browser. Do you
    have an idea without using any external module ? Or, what's the module
    that gives the best combination reliability-simplicity under both Unix
    and Win ?
    Yohan N. Leder, Jul 3, 2006
    #8
  9. In article <>,
    says...
    > Maybe \a might be considered short for 'alarm' or 'alert'...
    >


    I confirm that "print '\a';" produce a beep in DOS-box under Win2K as
    replied to Sherm P. just above in this thread.

    However, problem in taint mode was due to an error message which did the
    print line was never reached : solved now !
    Yohan N. Leder, Jul 3, 2006
    #9
  10. In article <>, -berlin.de
    says...
    > Perl calls it "alarm (bell)" (see perlop). It's a backslash escape
    > like "\n" and many more.
    >


    Effectively, I've tried too to run 'print "\a";' in the Komodo's
    interactive Perl shell and it produces 'BEL' on screen rather than
    something in speaker, confirming what you says.
    Yohan N. Leder, Jul 3, 2006
    #10
  11. In article <>, -berlin.de
    says...
    > If you don't know the answer, how do you know it's a "quick question"?
    >


    Because I said 'quick question' and not 'quick answer'.
    Yohan N. Leder, Jul 3, 2006
    #11
  12. In article <>,
    says...
    > Yes - I get a beep too under WinXP ActivePerl 5.8.4. This same beep can
    > be achieved by e.g. typing "echo", space, control-G and then Enter.
    > This should work in most/all terminals, as CTRL-G corresponds to
    > dec/hex 07 (BEL, bell, 0000111 in 7-bit ASCII) as the de-facto bell
    > signal.
    >


    Effectively, I remember now that this CTRL-G is often used in DOS batch
    listings.

    > My conclusion:
    > You can't know at Perl level whether or not the terminal will beep at
    > any character. It's just up to the shell. I would say this hasn't any
    > real importance too. Unless you want to program a singing shell or so
    >


    Oh no, the things was to indicate to an operator that a process is well
    running, producing this beep a every turn in a big loop. Knowing, of
    course, and here is the real reason that this 'human operator' is not in
    front of the screen all the time and has to be alerted by something
    resonant; whatever be the nature of the sound (a simpe beep is enough).

    Also, and as I said to Sherm P. in this thread too, I'm interesting to
    produce a sound (any sound) when the terminal is a web browser (in CGI
    environment) : do you have an idea for this second and different case to
    solve ?
    Yohan N. Leder, Jul 3, 2006
    #12
  13. Yohan N. Leder

    -berlin.de Guest

    Yohan N. Leder <> wrote in comp.lang.perl.misc:
    > In article <>, -berlin.de
    > says...
    > > If you don't know the answer, how do you know it's a "quick question"?
    > >

    >
    > Because I said 'quick question' and not 'quick answer'.


    Are you saying you wrote it to point out the obvious fact that the
    question was short? I don't believe you.

    Anno
    -berlin.de, Jul 3, 2006
    #13
  14. Yohan N. Leder wrote:

    > [..]
    > Oh no, the things was to indicate to an operator that a process is well
    > running, producing this beep a every turn in a big loop. Knowing, of
    > course, and here is the real reason that this 'human operator' is not in
    > front of the screen all the time and has to be alerted by something
    > resonant; whatever be the nature of the sound (a simpe beep is enough).


    #!/perl
    use strict;
    use warnings;
    $|++; # make sure to unbuffer output
    print "Running 1 to 10...\n";
    for (1..10) {
    sleep 2;
    print "\a$_ ";
    }
    print "\nend.";

    > Also, and as I said to Sherm P. in this thread too, I'm interesting to
    > produce a sound (any sound) when the terminal is a web browser (in CGI
    > environment) : do you have an idea for this second and different case to
    > solve ?


    In that case you should instruct the browser to play an external sound
    file, f.i. something like this (for Microsoft Internet Explorer only):

    #!/usr/bin/perl
    print "Content-Type: text/html; charset=iso-8859-1\n\n";
    $|++; # make sure to unbuffer output
    use strict;
    use warnings;
    use CGI::Carp qw(fatalsToBrowser);
    print '<html><body>
    <iframe id="s" name="s"
    src="http://www.dotinternet.be/temp/play.htm"
    style="display:none; visibility:hidden;">
    </iframe> Running 1 to 10...<br>';
    for (1..10) {
    sleep 2;
    print '
    <script type="text/javascript">
    window.frames.s.location.href =
    "http://www.dotinternet.be/temp/play.htm";
    </script>
    &nbsp; '.$_
    }
    print '<br>end.</body></html>';

    It uses the following files:

    http://www.dotinternet.be/temp/play.htm
    http://www.dotinternet.be/temp/file.mp3

    (P.S. Make sure to disable possible max runtime flags at Apache/CGI/OS
    level, if any)

    Hope this helps,

    --
    Bart
    Bart Van der Donck, Jul 3, 2006
    #14
  15. In article <>, -berlin.de
    says...
    > Yohan N. Leder <> wrote in comp.lang.perl.misc:
    > > In article <>, -berlin.de
    > > says...
    > > > If you don't know the answer, how do you know it's a "quick question"?
    > > >

    > >
    > > Because I said 'quick question' and not 'quick answer'.

    >
    > Are you saying you wrote it to point out the obvious fact that the
    > question was short? I don't believe you.
    >
    > Anno
    >


    Don't interprete, Anno. Here is my exact original sentence : "Very quick
    question this time." All attempt to change any word is an
    interpretation. Not a matter of believing, but reading only.
    Yohan N. Leder, Jul 3, 2006
    #15
  16. In article <>,
    says...
    > Hope this helps,
    >


    A lot, thanks Bart !
    Yohan N. Leder, Jul 3, 2006
    #16
  17. Yohan N Leder <> wrote:

    > However, problem in taint mode was due to an error message which did the
    > print line was never reached : solved now !



    So your "quick question" was not so quick.

    Why?

    Because you were getting error messages that you did not mention.

    Once again you display a lack of respect for your peers.

    This is becoming tiresome in the extreme.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jul 3, 2006
    #17
  18. Yohan N. Leder <> writes:

    > Nevertheless, because you talk about CGI orientation, it interest me too
    > to know how to produce a simple beep in internal speaker when script is
    > reached through web server and current STDOUT is a web browser.


    I think you mentioned earlier that you're writing an internal app on a LAN,
    so I won't get into the wisdom(?) of noisy pages on the WWW. ;-\

    > have an idea without using any external module?


    It depends on why you want the beep to happen. The simplest possible way
    would be to print an <object> and/or <embed> that refers to a sound file.

    If you want the beep to happen as the result of a specified server-side
    event, you could place the above in a hidden frame, and use JavaScript or
    a meta refresh to periodically update it from the server. Your CGI would
    return an empty (i.e. silent) HTML block until the watched-for event
    happens, then return the HTML that would load the sound.

    Note that you won't achieve precise synronicity this way - there will
    always be a variable-length delay between the time the beep is sent from
    the server and the time it's played in the browser. But if all you need is
    a "process finished" alarm of some sort, then even several seconds of lag
    would probably be acceptable.

    I've kept this intentionally brief, because big pieces of this would be
    implemented in client-side JS and HTML, which are off-topic in this group.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Jul 3, 2006
    #18
  19. Yohan N. Leder

    -berlin.de Guest

    Yohan N. Leder <> wrote in comp.lang.perl.misc:
    > In article <>, -berlin.de
    > says...
    > > Yohan N. Leder <> wrote in comp.lang.perl.misc:
    > > > In article <>, -berlin.de
    > > > says...
    > > > > If you don't know the answer, how do you know it's a "quick question"?
    > > > >
    > > >
    > > > Because I said 'quick question' and not 'quick answer'.

    > >
    > > Are you saying you wrote it to point out the obvious fact that the
    > > question was short? I don't believe you.
    > >
    > > Anno
    > >

    >
    > Don't interprete, Anno. Here is my exact original sentence : "Very quick
    > question this time."


    Reading *is* interpretation -- if that basic fact has escaped you your
    world view is simplistic indeed.

    > All attempt to change any word is an
    > interpretation. Not a matter of believing, but reading only.


    My interpretation is based on the half-dozen or so questions per week
    we get here that are announced as "quick", "easy", "simple", and so forth.
    It's a stereotype that invariably aims at attracting more attempts to
    answer the question. In the long run, that gets annoying. Yours was
    no different from any other of its kind.

    Anno
    -berlin.de, Jul 3, 2006
    #19
  20. -berlin.de writes:

    > My interpretation is based on the half-dozen or so questions per week
    > we get here that are announced as "quick", "easy", "simple", and so forth.


    Heh. That's not limited to this group. How many times has your boss asked
    you for a "quick little app" that wound up taking days to finish?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Jul 3, 2006
    #20
    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. Johann C. Rocholl

    Taint (like in Perl) as a Python module: taint.py

    Johann C. Rocholl, Feb 5, 2007, in forum: Python
    Replies:
    5
    Views:
    468
    Johann C. Rocholl
    Feb 6, 2007
  2. Louis Erickson
    Replies:
    2
    Views:
    202
    James Willmore
    Sep 3, 2003
  3. Ben
    Replies:
    17
    Views:
    227
  4. Dave Saville

    Find::File and taint mode

    Dave Saville, Nov 18, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    130
    Ben Morrow
    Nov 18, 2003
  5. kj

    Taint mode and PERL5LIB

    kj, Jun 11, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    312
    Ben Morrow
    Jun 14, 2004
Loading...

Share This Page