Hey,
I need to read a directory on a remote server which requires a user to be su.
The question is how to correctly read the server response and then to send a su password using IRIS device I/O API (I'm able to read other commands output such as uname, but can't figure out how to switch to su):
// Init SSH session
Set ..Session = ##class(%Net.SSH.Session).%New()
Set status = ..Session.Connect(..Server)
$$$ThrowOnError(status)
Set status = ..Session.AuthenticateWithUsername(..UserName, ..Password)
$$$ThrowOnError(status)
// SUDO
#Dim device
Set device = ""
Set status = ..Session.Execute("su " _ ..UserName, .device) // Is this correct?
$$$ThrowOnError(status)
Use device
#Dim response
Read !, "", response // Here I get a kind of infinite loop
Write ..Password
Close device




