# Via ssh access tty lines or run commands locally? [SOLVED]

## slugggerzzz

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 ...

----------

## Telemin

Hi,

Take a look at app-misc/screen, it is exactly what you want.

```

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-

----------

## truc

or tmux, very similar to screen

----------

## krinn

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

----------

## Telemin

While that is true for despatched processes, I'm not sure it is true in generality.

For example,

```

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-

----------

## krinn

bash will survive  :Razz: 

like all programs going to background, just like emerge in my example (that is python btw)

----------

## Telemin

Then try this:

```

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.

----------

## Ant P.

That's because the `for` loop is a bash builtin command.

----------

## Telemin

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-

----------

## slugggerzzz

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 !

----------

## krinn

 *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

----------

