0

Is there a way to write a script which can go over all the interactive bash shell processes running on the same computer one by one, and run some command in each interactive bash shell respectively?

  • Assume only bash, no zsh etc. but if there are other kinds of shells such as zsh, then all the shells.

  • "interactive" because the command I am going to run is to collect some information about interactive usage of a shell, for example running dirs or jobs and collecting their outputs from all the shells into a single list or file.

  • Two interactive shell processes are deemed different, if dirs or jobs gives different outputs in them.

Thanks.

  • I am not sure what you mean. Two interactive shell processes are deemed different, if dirs or jobs gives different outputs in them. – Tim Apr 2 '18 at 20:13
  • This may be related to unix.stackexchange.com/questions/15223/… and, as such, may be limited to shell initialization (e.g., '/etc/profile', '${HOME}/.bash_profile', '${HOME}/.bashrc', etc.). – Thomas N Apr 3 '18 at 14:24
  • I certainly don't see how you could unobtrusively attach to a running interactive shell process, run a command, and redirect it's output to a central file all without significantly affecting the existing user process. – Thomas N Apr 3 '18 at 14:27

Your Answer

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

Browse other questions tagged or ask your own question.