An interesting question about "print '\a'"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony Liu

    #1

    An interesting question about "print '\a'"

    We know that if we do

    print '\a'

    the bell will sound.

    Now, why do I hear the sound on my local machine when
    I run a python script on a remote host?

    I understand if I hear it when I do

    print '\a'

    on my local machine.

    Does the command get sent back to the client machine?

    Thanks.

    _______________ _______________ _______________ _____
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    Yahoo Mail: Your smarter, faster, free email solution. Organize your inbox, protect your privacy, and tackle tasks efficiently with AI-powered features and robust security tools.

  • Erik Max Francis

    #2
    Re: An interesting question about "print '\a'"

    Anthony Liu wrote:
    [color=blue]
    > We know that if we do
    >
    > print '\a'
    >
    > the bell will sound.
    >
    > Now, why do I hear the sound on my local machine when
    > I run a python script on a remote host?[/color]

    Because print '\a' just prints the BEL ASCII character, which most
    terminals respond by beeping. Since, when you're logged into a remote
    machine, it's your terminal that's displaying the output of your remote
    session, that's why you hear the beep on your local machine.

    --
    Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
    San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
    Maybe soul mates exist / After all
    -- Des'ree

    Comment

    • Chris F.A. Johnson

      #3
      Re: An interesting question about "print '\a'"

      On 2005-10-24, Anthony Liu wrote:[color=blue]
      > We know that if we do
      >
      > print '\a'
      >
      > the bell will sound.
      >
      > Now, why do I hear the sound on my local machine when
      > I run a python script on a remote host?
      >
      > I understand if I hear it when I do
      >
      > print '\a'
      >
      > on my local machine.
      >
      > Does the command get sent back to the client machine?[/color]

      The code is printed to stdout, which is your terminal. Your
      terminal interprets ^G as a beep.

      --
      Chris F.A. Johnson <http://cfaj.freeshell. org>
      =============== =============== =============== =============== ======
      Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
      <http://www.torfree.net/~chris/books/cfaj/ssr.html>

      Comment

      • bonono@gmail.com

        #4
        Re: An interesting question about &quot;print '\a'&quot;

        I thought that is just a "terminal" thing(extend ASCII that interpreted
        by the terminal)? If you have a terminal attached to a host, shouldn't
        this be making sound on the terminal rather than the server ? This not
        alsa or output to the server device, but straightly sending '\a' back
        to the client machine I believe.

        Anthony Liu wrote:[color=blue]
        > We know that if we do
        >
        > print '\a'
        >
        > the bell will sound.
        >
        > Now, why do I hear the sound on my local machine when
        > I run a python script on a remote host?
        >
        > I understand if I hear it when I do
        >
        > print '\a'
        >
        > on my local machine.
        >
        > Does the command get sent back to the client machine?
        >
        > Thanks.
        >
        > _______________ _______________ _______________ _____
        > Do You Yahoo!?
        > Tired of spam? Yahoo! Mail has the best spam protection around
        > http://mail.yahoo.com[/color]

        Comment

        Working...