Is it possible to enter keyboard shortcuts into a bash script? For example, I have tried typing in ^d
to substitute for control + d (logout) without success.
ubuntu@vfleet:~$ ^d
-bash: :s^d: substitution failed
ubuntu@vfleet:~$ ^D
-bash: :s^D: substitution failed
I am using screen to run a django development server in the background. One of the commands to run a particular screen as a daemon is control + a + d. The goal is to be able to enter in control + a + d into a bash script. For example:
python manage.py runserver
^a + d
Is this possible?
Edit:
A valid method of avoiding the keyboard shortcut in screen is linked by Eric Renouf in the comments below. screen -d -m sh -c "python manage.py runserver"
will start a development server as a daemon. This is a great solution for my particular problem, but it would still be nice to have a solution for the original question at hand.
xdotool
package is the solution here.
xdotool key ctrl+d
Full reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With