3

I am using .byobu/windows to start up some screen sessions, and I'm trying to start a script that will exit to an interactive shell once it has completed. Is this possible?

I've tried:

screen -t test /bin/bash -i /path/to/script
screen -t test /bin/bash - /path/to/script

I realize I could just add a /bin/bash to the end of the script, but I don't want that as a solution for when I run the script in a shell...

  • What does the script you want to run before the command prompt do? – Bananguin Aug 14 '13 at 5:02
2

If it's important to use the same shell use the --rcfile flag.

$ cat test.bashrc 
ls
PS1='TEST \$'
$ screen -t test bash --rcfile test.bashrc -i
a.file  b.file  test.bashrc
TEST $

If your .bashrc is setting the environment, be sure to source it.

| improve this answer | |
2

The only reasonable way that I've found to run a command, leaving the output and an interactive shell behind within screen is to use the 'stuff' command to execute the command:

screen -t title1 bash
stuff 'ls /tmp^M'  # in vim type control-v control-m to insert the return at the end
| improve this answer | |
0

If possible, just start two commands.

screen -t test /bin/bash /path/to/script; /bin/bash

If you are only able to start one command, try this:

/bin/bash -c 'screen -t test /bin/bash /path/to/script; /bin/bash'
| improve this answer | |

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.