Screen Command with Bash Scripting
I'm trying to create a BASH script that uses screen to connect to a remote system and run a few commands. However there aren't any instances of screen running when the script is run. Is there a way to start an instance of screen in the background so that I can then send commands to it using 'screen -X'? The current problem is that if I invoke screen it just starts the terminal in the foreground and BASH loses control.
Thanks. |
To run any command in the background,
add an & to the end of the command. |
For whatever reason, screen decides not to go to the background when run as "screen &". Any ideas?
|
Hello.Try
Code:
screen -d -m |
+1 jmfv
some more screen that might help $: screen -d -m links google.com $: screen -d -m links slackware.com $: screen -r There are several suitable screens on: 31426..{MY HOST NAME} (Detached) 31434..{MY HOST NAME} (Detached) Type "screen [-d] -r [pid.]tty.host" to resume one of them. $: screen -r {31426} the {31426} is the first num from screen -r output in previous command. This will bring up the `links google.com` page. So now you should have your links up to google.com on your screen. You can surf around and whatever, or if its a script you could be watching the output. To detach this screen and go back to your normal console hit <CTRL>+<A> and then <CTRL>+<D>. Now the screen to links google.com will be back in the background. There are lots of other <CTRL>+<D> and then <CTRL>+<KEY> commands check out the man file for more. |
Awesome. Thanks very much.
|
All times are GMT -5. The time now is 12:00 AM. |