Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to execute a script locally. The problem is, it needs to use screen and send the ctrl d command.

How would i do this? The script will be on my local windows machine. i can use winscp, putty, mingw and other apps.

share|improve this question
1  
Assuming you mean Ctrl-a d for immediately detaching. –  forcefsck Apr 2 '11 at 19:05

3 Answers 3

You can use expect (expect home page, included in most unix software distributions) to script interactions with programs that run in text terminals.

However, there's probably a simpler way of doing what you're trying to do. You can send commands to a screen session from any command line, and you can use screen's stuff command to insert input into a screen window. See Why is screen seemingly doing nothing with commands passed with -X?, Sending input to a screen session from outside for examples.

screen -S sessionname -p windowname -X stuff $'\004'

If this answer isn't helping you, give more information about what you're trying to do.

share|improve this answer

From screen(1) manual

   -d|-D [pid.tty.host]
        does not start screen, but detaches the elsewhere running screen
        session. It has  the same  effect  as typing "C-a d" from screen’s
        controlling terminal. -D is the equivalent to the power detach key.
        If no session can be detached, this option is ignored. In combination
        with the -r/-R option more powerful effects can be achieved:

I usually use screen -AmdS sessionname commandline to run a commandline in a screen session and immediately detach. e.g. running a screen from a cronjob

@reboot /usr/bin/screen -AmdS shoutcast /home/foo/sc_serv /home/foo/sc_serv.conf

Adding new commands on an existing detached screen and detach immediately.

screen -dr sessionname -X commandline
share|improve this answer

Your arrangement doesn't make any sense to me. Are you asking how to send keys to screen from something outside screen? You might use expect for that senario. You can also launch screen with a custom config file to change the ctrl-d to something easier to send.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.