If I want to simulate an enter key pressed,I just use:
echo -ne '\n' | mycommand
But "mycommand" requires to wait some seconds before actually press enter key. How could I wait some seconds before simulate the enter key pressing?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
(sleep 12; echo) | mycommand
mycommand will read an empty line after 12 seconds and see end-of-file straight after. If that's a problem, you can add a delay after as well:
(sleep 12; echo; sleep 5) | mycommand
expect to send input based on what the command outputs (it also uses pseudo-terminals which makes it look like there's a real user).