Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > need simple beep and taint mode

Reply
Thread Tools

need simple beep and taint mode

 
 
Yohan N. Leder
Guest
Posts: n/a
 
      07-02-2006
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 ?
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      07-02-2006
Yohan N. Leder <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
anno4000@zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-03-2006
Yohan N. Leder <(E-Mail Removed)> 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
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      07-03-2006
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

 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      07-03-2006
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

 
Reply With Quote
 
anno4000@zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-03-2006
Bart Van der Donck <(E-Mail Removed)> 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
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      07-03-2006
http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de wrote:

> Bart Van der Donck <(E-Mail Removed)> 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

 
Reply With Quote
 
Yohan N. Leder
Guest
Posts: n/a
 
      07-03-2006
In article <(E-Mail Removed)>, sherm@Sherm-
Pendleys-Computer.local says...
> Yohan N. Leder <(E-Mail Removed)> 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:rocess::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 ?
 
Reply With Quote
 
Yohan N. Leder
Guest
Posts: n/a
 
      07-03-2006
In article <(E-Mail Removed) .com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) 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 !
 
Reply With Quote
 
Yohan N. Leder
Guest
Posts: n/a
 
      07-03-2006
In article <(E-Mail Removed)>, (E-Mail Removed)-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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Taint (like in Perl) as a Python module: taint.py Johann C. Rocholl Python 5 02-06-2007 09:37 AM
Mac LC475 (Quadra 650) plays "beep beep beep beep" Uplink Computer Information 0 04-12-2006 10:37 PM
Taint - having some real trouble here, taint/perl experts, please help Ben Perl Misc 17 10-24-2003 12:22 PM
Problem with Date::Manip, taint mode, and CGI::Carp. Louis Erickson Perl Misc 2 09-03-2003 02:02 AM
BEEP! BEEP! BEEP! Arg! :( Kevin Low Computer Information 0 07-06-2003 08:29 AM



Advertisments