Hi,
I am executing a shell script which returns value 0 or 1 based on some conditions, using DSExecute function in a routine(transform function)
Ans=Output<1> worked fine and i got the required output.
Because of some error in the script, the script is now returning some error statements along with the return code(0/1) that I want. But I want only the last value (either 0/1) returned from the script whether it executes successfully or not.
How can I extract only the return value from the dynamic output.
Regards,
ssunda
Extracting required string from routine's return value
Moderators: chulett, rschirm, roy
Hi,
My issue is resolved.
While using the DSExecute function, I was earlier using
Call DSExecute("UNIX","sh ScriptName",Output,SystemReturnCode)
Ans=Output<1>
Now I tried getting the required output by using awk.
Solution:
Call DSExecute("UNIX","sh ScriptName 2>&1 | awk '{line=$0} END {print line}'",Output,SystemReturnCode)
Ans=Output
awk is acting on the output of sh command. Each record is identified as $0. The block after END will be processed once all the records are processed. So, "line" will contain the last line and I am printing it.
Regards,
ssunda.
My issue is resolved.
While using the DSExecute function, I was earlier using
Call DSExecute("UNIX","sh ScriptName",Output,SystemReturnCode)
Ans=Output<1>
Now I tried getting the required output by using awk.
Solution:
Call DSExecute("UNIX","sh ScriptName 2>&1 | awk '{line=$0} END {print line}'",Output,SystemReturnCode)
Ans=Output
awk is acting on the output of sh command. Each record is identified as $0. The block after END will be processed once all the records are processed. So, "line" will contain the last line and I am printing it.
Regards,
ssunda.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: