I would like to know how to run make a terminal program run automatically at reboot with preset input variables. What I am trying to do is run bro control which is a terminal program that requires input. I know that when you run cron jobs, that are terminal commands, it does not show the terminal screen. I would like it to run like that in the background with predefined inputs. The command also needs root permissions which if there is a cron job way of doing this, that is easy, just put it in your root cron tab.
An example of the code to be run automatically:


last time I ask this question no one had an answer. I am hoping that by making it broader and more understandable someone will have an answer. I have researched this and cannot find an answer. Hopefully, someone will know the way to do this. By the way, I am running Linux-Mint.

  • What have you tried so far? If you want a program to run on boot, you'll need to put it in your init scripts somewhere. I think Linux Mint uses systemd, in which case you'd create a systemd unit. Alternatively, there are @reboot entries in the crontab – Fox May 2 '17 at 16:08
  • I have run commands at reboot before using cron. I just have no idea how to run the command to run the program at reboot with predefined inputs. – Nathan Hill May 2 '17 at 16:11

Save your desired input into a file, and pass that file as an input argument to the program.

my_command --some_flags_if_needed < path/to/file/containing/input

  • You might mention that if it accepts input on stdin and one doesn't want a file, one can do printf '%s\n' 'input line 1' 'input line 2' … | my_command – Fox May 2 '17 at 16:19
  • since I need an input and then it to finish doing something and to input an another input to close the program how would that work – Nathan Hill May 2 '17 at 16:31
  • I know I would put the @reboot broctl < path/to/file/with/input and have that file have start wrote in it, but then how do I make it so after it does that it inputs exit? Can I have two files and have it input one after the other somehow? @Michael – Nathan Hill May 2 '17 at 16:43
  • 1
    As far as I'm aware, you should be able to just put start and exit in the same file (on separate lines). It should consume the first line, handle it, then consume and handle the second. Unless there's a specific time delay you need? – Michael Stroud May 2 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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