Find the answer to your Linux question:
Results 1 to 5 of 5
Hi! I'm currently writing a C++ application to manage some screen functions in Debian(server). However this issue have bothered me for 2 days now... What I want to do is ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4

    Send enter command to screen?

    Hi!

    I'm currently writing a C++ application to manage some screen functions in Debian(server).

    However this issue have bothered me for 2 days now...

    What I want to do is to send a command to an attached screen which is running.
    Used the following command:
    Code:
    screen -S screenwindow
    So I send a command with the -X parameter, which works just fine...
    Code:
    screen -S screenwindow -X stuff yes
    The command I want to send is "yes" and it does appear in my screen window when I attach it.

    But the problem is that I need it to submit it... well I need to press "enter" and I've been looking everywhere on how to do that.

    Because right now it hangs on a line like this:
    Code:
    Something here, do you want bla bla: yes
    Obviously I could just press enter myself, but the problem is that it's running as a deamon and but it is supposed to do this all by itself .


    So are there any way I can submit it?

    Thanks

    - realchamp.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Try this:
    Code:
    screen -S screenwindow -X stuff $'\012'
    $'\012' means "newline character".
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    Quote Originally Posted by Cabhan View Post
    Try this:
    Code:
    screen -S screenwindow -X stuff $'\012'
    $'\012' means "newline character".
    Hi! Thanks for the answer!

    Unfortunately it did not work.

    I wrote that line, after entering the command which would print "yes" and it didn't even register that I wrote the $ '\012'


    Thanks,
    - realchamp.

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    i would send a carriage return (\r), and maybe even followed by a new line (\r\n)

    I'm not sure what the corresponding value is with regards to what cabhan posted earlier

  5. #5
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    Quote Originally Posted by coopstah13 View Post
    i would send a carriage return (\r), and maybe even followed by a new line (\r\n)

    I'm not sure what the corresponding value is with regards to what cabhan posted earlier
    Hey. Sorry for not replying.

    This solved the problem. I added the "\r" in the back.

    Thanks alot!

    - realchamp.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...