This project is read-only.

logon to group

Aug 10, 2011 at 9:56 PM


In prod, i do not have permission to execute the .sh file. but if i use logon groupuser and execute the .sh able to run the file.

how can i run logon groupuser and execute .sh file using .net.

i am getting Error code 127 : ksh: logon:  not found.


Aug 11, 2011 at 12:26 PM

When you use SshCommand object to execute command, it simply executes one(or chain) command at a time without running it in the shell.

My guess is that "ksh" defined somewhere in default shell and therefor not available in this context.

In this case you might want to try "Shell" object as a solution, where you can send and receive data to the shell, pretty much like you do when you connect using putty or other client.


Hope it helps,



Aug 11, 2011 at 3:55 PM

I understand, but my situation is this,

i am developing on windows client that lists reports that needs to run in unix server.

Each reports when invoke has to trigger sh xxx/xx/xx/ file which will run for 4 to 5 hours.

user should able to trigger any reports  one by one, in any order. and result of the command and time taken to execute and errro details if any , should be logged in a txt file.

i have done this using sshclient and threading concept.

but the user does not have permission in prod to execute this.

usually , we switching to group by logon groupuser, then we execute the .sh script file in the putty.

In order to achieve this i tried

1) "logon reportAdmin; /data/admin/" in the  sshclient command but it does not work.

2) tried with shell option in sshclient. able to trigger the report but user should be able to run other reports in the same shell (too many shell logon , will be problem ) and gets the each report error status, result, exit code and timing of the report.

Please help me out...


Aug 12, 2011 at 12:55 AM


I am able execute the "logon reportAdmin; /data/admin/" using creating shell. but i am not able track if throws any error.

shell.errorOccurred does not capture the script errors.

 i used the following code: Please sugges how to capture report errors.

                        var shell = client.CreateShell(command, output, output, "xterm", 80, 24, 800, 600, "");
                        shell.Stopped += delegate(object sender, EventArgs e)
                        shell.ErrorOccurred += delegate(object sender, ExceptionEventArgs e)
                            Utils.writeToLogFile("error Occured ");
Aug 15, 2011 at 2:58 PM

script errors should be capture by your script and then either output to the screen, save into the file or something else.

sheel.ErrorOccured raised only if SSH protocol error occurred, so it would be very rare.



Aug 15, 2011 at 4:12 PM
Edited Aug 15, 2011 at 4:20 PM

yes, but i like this way ,Which should say the Command executed without error. i should say

if shell.IsErrorInScript then

alert shell.cmderror



Aug 17, 2011 at 2:34 PM

well, unfortunately there is no way for me to say if your script was executed successfully or not, since all shell does is send some data to the terminal and then receives some data back, and what this data means is up to the user.

Thats why there is SshCommand object, where you can execute a single command and get response back for this executed command.


There are some pros and cons in each scenario, unfortunatly you need to pick which fits you best.