Not getting correct exit status code (ExitStatus) - WeOnlyDo Discussion board

Not getting correct exit status code (ExitStatus) (wodSSH / wodSSH.NET)

by Jatin Mehta, Friday, March 10, 2006, 09:39 (6833 days ago)

Hi,

I'm using wodSSH in my ASP pages. My problem is ExitStatus property. It is not showing correct exit status. It always show me 0. If I check on server using echo $? then I get correct exit status codes.
I'm using Execute method to execute commands on server (unix).
Please let me know why is this happening? Am I doing something wrong in my ASP script?
Here is the snippet from function I made:

--------------------------------
Set oSSH = Server.CreateObject( WeOnlyDo.wodSSHCom.1 )
oSSH.Blocking = 1
oSSH.LicenseKey = WOD_LICENSE_KEY

'set access details
oSSH.Hostname = sHostName
oSSH.Login = sLogin
oSSH.PrivateKey = oSSHKey

'settings for connection
oSSH.Authentication = 2
oSSH.Protocol = 3
oSSH.Encryption = 7
oSSH.Compression = 6

'Make connection
oSSH.Connect

'shell info
oSSH.WaitFor sWaitFor
oSSH.Prompt = sPrompt

'execute command
sOutput = oSSH.Execute(sCommand & vbLf)
sOutput = sOutput & Exit code: & oSSH.ExitStatus

'disconnect the session
oSSH.Disconnect
--------------------------------

Do any settings on SSH server needs to be tweak for ExitStatus property to work?
Do I need to change anything in my code?
Also, is there any place where I can find example ASP codes?

Thanks in advance.

Regards,
Jatin

Re: Not getting correct exit status code (ExitStat

by wodSupport, Friday, March 10, 2006, 12:32 (6833 days ago) @ Jatin Mehta

Jatin,

I'm pretty sure component behaves correctly. You executed remote shell upon connection, and that was successful, so component reports ExitStatus = 0 since that's what it receives when you disconnect. If you, on the other hand, set up Command property prior to connecting, and error happens, ExitStatus would return such error.

Can you try something like that?

Kreso

Re: Not getting correct exit status code (ExitStat

by Jatin Mehta, Saturday, March 11, 2006, 04:53 (6833 days ago) @ wodSupport

Thanks Kreso for your reply.

I tried setting Command property before calling Connect method.
It executed perfectly but I get nothing (null) in ExitStatus property regardless of the actual exit status of the command.
I'm sure I'm doing something wrong with this, but can't figure out.

Also, how can I get output of command if I'm not using Execute method and using Command property in ASP.

Thanks for your help.

-Jatin

Re: Not getting correct exit status code (ExitStat

by Jatin Mehta, Saturday, March 11, 2006, 05:20 (6832 days ago) @ Jatin Mehta

Hi...

Sorry my mistake. I've corrected the error in my code. Now, I get correct Exit codes.
Now, can you help me with output of command passed in Command property. How can I get that in ASP?

Thanks,
Jatin

Thanks Kreso for your reply.

I tried setting Command property before calling Connect method.
It executed perfectly but I get nothing (null) in ExitStatus property regardless of the actual exit status of the command.
I'm sure I'm doing something wrong with this, but can't figure out.

Also, how can I get output of command if I'm not using Execute method and using Command property in ASP.

Thanks for your help.

-Jatin

Re: Not getting correct exit status code (ExitStat

by wodSupport, Saturday, March 11, 2006, 20:09 (6832 days ago) @ Jatin Mehta

Jatin,

you should call Receive method to get output of the application. Call it more than once, until error connection closed occurs. Naturally, you must trap the error so it's not shown in ASP.

Kreso

Re: Not getting correct exit status code (ExitStat

by Jatin Mehta, Monday, March 13, 2006, 04:18 (6831 days ago) @ wodSupport

Thanks Kreso... for all your help.

It's working perfectly now. [:smile:]