View previous topic :: View next topic |
Author |
Message |
slugggerzzz n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/78445018150774e10701b1.jpg)
Joined: 07 Mar 2012 Posts: 65 Location: Manchester, UK
|
Posted: Wed Mar 07, 2012 3:40 pm Post subject: Via ssh access tty lines or run commands locally? [SOLVED] |
|
|
Via ssh access tty lines or run commands locally? Possible?
Hey,
I was looking into what’s the best way to run commands locally on the machine.
Is it possible to fire up a SSH console but be mirroring the local tty lines instead of using a pts line ?
Or what other possible ways can i run commands locally?
Realistically i could do with something so i get connect remotely, set off a command and then reconnect later to the same session.
Any ideas ?
Thanks in advance ... _________________ Slugggerzzz ...
Last edited by slugggerzzz on Thu Mar 08, 2012 9:05 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Telemin l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/14625081734b55c874a3922.png)
Joined: 25 Aug 2005 Posts: 753 Location: Glasgow, UK
|
Posted: Wed Mar 07, 2012 3:41 pm Post subject: |
|
|
Hi,
Take a look at app-misc/screen, it is exactly what you want.
Code: |
me@remotebox $ screen
-- enter screen and do something e.g
me@remotebox(screen) $ emerge -uNDav world
--now ctrl-a d detaches from the screen but leaves it running
--logout and log back in later, via ssh or locally
me@remotebox $ screen -r
--- reconnects to running screen
|
Hi from a fellow Mancunian
-Telemin- _________________ The Geek formerly known as -Freestyling-
When you feel your problem has been solved please add [Solved] to the topic title.
Please adopt an unanswered post |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
truc Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/128604942846f4cd99d01cb.jpg)
Joined: 25 Jul 2005 Posts: 3199
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krinn Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/gallery/Blade Runner/movie_blade_runner_howl.gif)
Joined: 02 May 2003 Posts: 7470
|
Posted: Wed Mar 07, 2012 9:01 pm Post subject: |
|
|
you might not get the ability to reconnect to the session, but if you just want a program running thru ssh even you close the ssh session, you can just run it in background
emerge --sync &
your emerge --sync will succeed even if you disconnect from the host |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Telemin l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/14625081734b55c874a3922.png)
Joined: 25 Aug 2005 Posts: 753 Location: Glasgow, UK
|
Posted: Wed Mar 07, 2012 9:45 pm Post subject: |
|
|
While that is true for despatched processes, I'm not sure it is true in generality.
For example,
Code: |
for f in *; echo $f >> md5list; do md5sum $f >> md5list; done &
|
in a directory of many large files, or some other loop that will not instantly complete. In cases like this I'm not sure that the loop will finish if you disconnect, as surely bash gets killed as soon as the sshd daemon kills the dead session?
-Telemin- _________________ The Geek formerly known as -Freestyling-
When you feel your problem has been solved please add [Solved] to the topic title.
Please adopt an unanswered post |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krinn Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/gallery/Blade Runner/movie_blade_runner_howl.gif)
Joined: 02 May 2003 Posts: 7470
|
Posted: Wed Mar 07, 2012 11:35 pm Post subject: |
|
|
bash will survive
like all programs going to background, just like emerge in my example (that is python btw) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Telemin l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/14625081734b55c874a3922.png)
Joined: 25 Aug 2005 Posts: 753 Location: Glasgow, UK
|
Posted: Thu Mar 08, 2012 12:50 am Post subject: |
|
|
Then try this:
Code: |
for a in {1..10};do touch $a; sleep 5; done &
logout
|
Then when you log back in see how many files you have. I don't get 10 when I try it. _________________ The Geek formerly known as -Freestyling-
When you feel your problem has been solved please add [Solved] to the topic title.
Please adopt an unanswered post |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Ant P. Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Thu Mar 08, 2012 1:44 am Post subject: |
|
|
That's because the `for` loop is a bash builtin command. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Telemin l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/14625081734b55c874a3922.png)
Joined: 25 Aug 2005 Posts: 753 Location: Glasgow, UK
|
Posted: Thu Mar 08, 2012 8:42 am Post subject: |
|
|
Which was precisely my original point. Krinn's statement is not true in all generality, and since I use one liners of that form fairly often, which take a non-neglible time to complete I am sure that others would as well and was aiming to avoid confusion due to overly general statements.
-Telemin- _________________ The Geek formerly known as -Freestyling-
When you feel your problem has been solved please add [Solved] to the topic title.
Please adopt an unanswered post |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
slugggerzzz n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/78445018150774e10701b1.jpg)
Joined: 07 Mar 2012 Posts: 65 Location: Manchester, UK
|
Posted: Thu Mar 08, 2012 9:03 pm Post subject: |
|
|
Thanks for the replies, i have got to say that giving the command to the ampersand has not been very successful in what I'm doing, running programs yeah.
Any how i tested screen and well its just what i wanted really.
Thanks for the feedback and i will mark this one as solved.
And hey Telemin, nice to know i am not the only one ! _________________ Slugggerzzz ... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krinn Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/gallery/Blade Runner/movie_blade_runner_howl.gif)
Joined: 02 May 2003 Posts: 7470
|
Posted: Fri Mar 09, 2012 5:44 pm Post subject: |
|
|
Telemin wrote: |
Then when you log back in see how many files you have. I don't get 10 when I try it. |
I don't know what bash version you use, because when i try it, i get 10 files on my host |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|