Home > Enterprise >  bash interact just once
bash interact just once

Time:11-27

I want to write a script for Ubuntu, which open a terminal-emulator, which only allows users interact with it only once. After finish running user's first command typed in, the terminal close on itself automatically, which is kind of like Win R on windows OS. How should I do that?

I try script like gnome-terminal -- bash -c "read cmd && $cmd", but there's two problem:

  1. No auto-complete on user inputting commands;
  2. Commands from .bashrc, .bash_aliases are not recognized.

CodePudding user response:

You can try :

gnome-terminal -- bash --rcfile <(cat ~/.bashrc; echo 'PROMPT_COMMAND="PROMPT_COMMAND=exit"')

I don't have Ubuntu to test at the moment, but bash ... part worked.

  • Related