Question: I've got a code in a dropdown box on my userform. Every time the user moves away from the drop down box, the code checks whether the value put by the user is correct (i.e. matches a list). If it doesn't, it triggers a message box. Here is my code:

```
Private Sub CmboxModifyRoute_Exit(ByVal Cancel As MSForms.ReturnBoolean)

UserValue = CmboxModifyRoute.Value
counter = 0
Cell = Range("C15").Value

If UserValue = "" Then Exit Sub

Do While (counter < 35 And Cell <> UserValue) 'checking if UserValue is valid
    counter = counter + 1
    Cell = Range("C15").Offset(counter, 0).Value
Loop

If counter > 34 Then 'if invalid, then display message box
    MsgBox "Invalid", vbExclamation
End If

End Sub

```

The problem occurs when I quit the userform with the "X" button or "Cancel" button. If the UserValue is invalid, it still shows me the "Invalid" message box after I have already quit the userform. I don't want it, I just want the userform to unload. How can I deal with this? Many thanks!

Answer: 
The commands following `ssh machine` in a script are not run on the machine. They will be run on the local machine once the `ssh` exits.

Either specify the commands to run as an argument of `ssh`, or alternatively, run ssh and make it read the commands from standard input, and send the commands to it.

```
ssh machine ls
# or
echo ls | ssh machine

```
You seem to be a little confused as to what runs where.

```
ssh -o ConnectTimeout=10 $1 'exit'

```

will connect to $1, run exit, and disconnect. 

```
ssh -o ConnectTimeout=10 $1 'echo hello world' 

```

will print hello world on 
the server and then disconnect.

ssh $1

will open up a shell on the remote. After the shell has ended, the following commands will run locally.

```
echo "SRV=`cat /etc/puppet/puppet.conf | grep -i srv_domain | awk '{print $3}'`"
echo $SRV
echo "puppetMaster=`host -t srv _x-puppet._tcp.$SRV | head -1 | awk '{print $8}' | cut -f1 -d"."`"
echo $puppetMaster
'exit'

```

What you probably want is start bash on the remote and forward to it the commands you want to give it via stdin.

```
echo "my commands" | ssh $1 bash

```

Technically, you don't need that bash -- ssh will start bash even without it (but with different rc files).