OpenSSH return codes


I am trying to code based on the return codes from openssh:sftp and am seeing what looks like unusual behavior. If sftp fails to put a message because of directory or file permissions, it writes the error to ‘error’, but sends back a successful return code (0) in ‘status’. Is this expected behavior? Also it seems like the ssh connection information (whether verbose or not) is always written to ‘error’ whether the connection is successful or not. I can work around this, but wanted to know if this is the same behavior others are seeing. thanks.



I am running into the exact same problem. Have you found a solution? If you have I would be very apprciative to know how you did it.


No I was not able to resolve this and had to code around the reply received in ‘error’. Apparently, if the ssh connection is successful, a ‘0’ is returned regardless of whether or not the actual file transfer was successful.

Hi All,

I have all the necessary OpenSSH set up and able to login to SFTP host without password from cmd line also. The question is what is the difference between pub.openssh:sftp and pub.openssh:ssh services in OpenSSH package.
I set the following values to list the files in pub.openssh:sftp service as
remotehost to-
remotecmd to - ls abc/ where abc is my remote directory on SFTP host
it is listing all the files.

How to retrieve only files that are matching a particular pattern:confused:. I tried with many options on pub.openssh:ssh service as well but to no avail. Please help me out if some body has worked or has any work around to implement this scenario.


Hi Experts,

Please help me!! Its pretty urgent.


Hi Experts,

Can anyone help me with this.


Hi Datta,

I am having the same requirement. I would like to get the output as list type when I execute the ls command and after that I want to retrieve files which have a particular pattern.

How can we achieve this. Please let me know.
Many Thanks.

Basically, you’ll need to filter the list yourself. Then retrieve each file that passes the filter.