Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Via ssh access tty lines or run commands locally? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
slugggerzzz
n00b
n00b


Joined: 07 Mar 2012
Posts: 65
Location: Manchester, UK

PostPosted: Wed Mar 07, 2012 3:40 pm    Post subject: Via ssh access tty lines or run commands locally? [SOLVED] Reply with quote

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
View user's profile Send private message
Telemin
l33t
l33t


Joined: 25 Aug 2005
Posts: 753
Location: Glasgow, UK

PostPosted: Wed Mar 07, 2012 3:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Wed Mar 07, 2012 5:08 pm    Post subject: Reply with quote

or tmux, very similar to screen
_________________
The End of the Internet!
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed Mar 07, 2012 9:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Telemin
l33t
l33t


Joined: 25 Aug 2005
Posts: 753
Location: Glasgow, UK

PostPosted: Wed Mar 07, 2012 9:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed Mar 07, 2012 11:35 pm    Post subject: Reply with quote

bash will survive :P
like all programs going to background, just like emerge in my example (that is python btw)
Back to top
View user's profile Send private message
Telemin
l33t
l33t


Joined: 25 Aug 2005
Posts: 753
Location: Glasgow, UK

PostPosted: Thu Mar 08, 2012 12:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Thu Mar 08, 2012 1:44 am    Post subject: Reply with quote

That's because the `for` loop is a bash builtin command.
Back to top
View user's profile Send private message
Telemin
l33t
l33t


Joined: 25 Aug 2005
Posts: 753
Location: Glasgow, UK

PostPosted: Thu Mar 08, 2012 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message
slugggerzzz
n00b
n00b


Joined: 07 Mar 2012
Posts: 65
Location: Manchester, UK

PostPosted: Thu Mar 08, 2012 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Mar 09, 2012 5:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum