-1

I am trying to write a basic write for Linux that opens a terminal window, sends a command, and then sends a character such as "Y" or "N". Also, after a fixed period of time, stop the process.

So far I can get the window and command running using:

gnome-terminal -e "command"

Anyone know how I can send a character like "Y" after that command executes in the new terminal window as well as stop the process in that window after a fixed period of time?

  • hope this help. [link](http://askubuntu.com/questions/5363/how-to-start-a-terminal-with-certain-text-already-input-on-the-command-line). you can create an executable file which contains necessary logic. – bekt Sep 28 '15 at 02:11

1 Answers1

0

Create your executable file which allow to send a character into new window terminal.

example yourexecutable.sh (refer to @ændrük example):

#!/usr/bin/expect -f

# Get a Bash shell
spawn -noecho bash

# Wait for a prompt
expect "$ "

# Type something
send "my text to be posted"

# Hand over control to the user
interact

exit

then by using timeout command run this command

gnome-terminal -e "timeout 10 ~/yourexecutable.sh"
Community
  • 1
  • 1
bekt
  • 597
  • 4
  • 16