This project is read-only.

Running nuhup command using SSH.NET

Dec 3, 2013 at 10:09 PM
Edited Dec 3, 2013 at 10:10 PM
What is wrong with this code?
using (var client = new SshClient("host", "user", "password"))

                   // var result = client.RunCommand(<ValidCommand>);  // command executing and doing fine
                    var result2 = client.RunCommand("nohup <ValidCommand> &"); // nothing happend - error and result are empty. On linux server nohup.out doesn't appear


How to run nohup command? What is wrong with this code?

Thanks in advance for your answers.
Nov 5, 2014 at 2:02 PM
I'm having the same problem in my application. I become only error 126. Can you please help us?
Nov 5, 2014 at 3:01 PM
126 means "Permission Denied".
» ssh test "nohup /dev/null"; echo $?
nohup: failed to run command ‘/dev/null’: Permission denied
Marked as answer by drieseng on 11/5/2014 at 11:44 AM
Nov 6, 2014 at 9:22 AM
But when I'm using PuTTY, or running the same command without nohup it's all fine. And maybe I've made a mistake, it's not error code 126, but exit status 126.
Nov 6, 2014 at 9:49 AM
Edited Nov 6, 2014 at 10:02 AM
Check the content of STDOUT and STDERR.

According to the nohup man page:
126 nohup found the utility program but could not invoke it.
RunCommand() is not the same like starting the command in a full (Putty-)Shell.
You have to compare it to the command option of your ssh client (e.g. plink):
C:\Windows\System32>"c:\Program Files (x86)\PuTTY\plink.exe" test "nohup /dev/null"
nohup: failed to run command ÔÇÿ/dev/nullÔÇÖ: Permission denied
This does the same like RunCommand() in SSH.NET.