User bio
404 bio not found
Member since Mar 12, 2024
Posts:
Ludwig has not published any posts yet.
Replies:

Hi Fahima,

Perhaps something along these lines will be useful to you (Note: You need to add some more checks, but you get the gist) 

 set status=##class(%XML.TextReader).ParseFile(<filepath>,.textreader)
 do textreader.ReadStartElement("content")
 
 while textreader.Read() {
	if (textreader.NodeType="endelement")&&(textreader.Name="content") {
		quit
	}
	
	// Handle values of content element here
 }

Hi Dmitrii,

The issue stems from the fact that 'su' is designed to run interactively, so it expects a tty to read the password securely. You have to find a way to run a command as another user non-interactively.

If you have the option, you can use 'sudo' with the -S flag instead.
  -S, --stdin                   read password from standard input

Example:

#dim cmd As %String = "echo "_password_" | sudo -S ls"
set status = Session.Execute(cmd, .device)
$$$ThrowOnError(status)
       
use device
read response:2
use 0
zwrite response


Otherwise 'expect' might work,
 

expect -c 'spawn su - root -c "ls"; expect "Password :"; send "password\n"; interact
Certifications & Credly badges:
Ludwig has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Ludwig has no followers yet.
Following:
Ludwig has not followed anybody yet.