extracting required string from routine return value
Moderators: chulett, rschirm, roy
extracting required string from routine return value
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
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
Hi,
Forgot providing example of output from the script.
When we got error, the output was as follows:
tail: cannot open input
error: No such file or directory on file /opt/ofa/logs/tgt_testA.log
1
I can get the last line of output using
Ans=Output<3> . But next time if the error differs, and i have 4 lines of error, then this will not work.
Any inputs will be helpful.
Thnx,
ssunda.
Forgot providing example of output from the script.
When we got error, the output was as follows:
tail: cannot open input
error: No such file or directory on file /opt/ofa/logs/tgt_testA.log
1
I can get the last line of output using
Ans=Output<3> . But next time if the error differs, and i have 4 lines of error, then this will not work.
Any inputs will be helpful.
Thnx,
ssunda.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Code: Select all
Ans = Field(Output, @FM, Count(Output,@FM) + 1, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi Chullet, Ray
I tried both options : Count function and redirecting error messages to some file or /dev/null
Both of them are not working.
Redirecting output is not working some times. When I had an error of missing some files, it redirected all error messages except one message .
I tried using the following code in my routine :
Ans = Field(Output, @FM, Count(Output,@FM) + 1, 1)
But it is not returning anything.
Regards,
ssunda.
I tried both options : Count function and redirecting error messages to some file or /dev/null
Both of them are not working.
Redirecting output is not working some times. When I had an error of missing some files, it redirected all error messages except one message .
I tried using the following code in my routine :
Ans = Field(Output, @FM, Count(Output,@FM) + 1, 1)
But it is not returning anything.
Regards,
ssunda.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What's parallel got to do with any of this? We are discussing a BASIC routine for goodness sake. I know you've got yourself a 'solution' but it's overly complex and it can be easily handled in other ways as mentioned here.
If you want to pursue this we can. The count and redirection do work.
If you want to pursue this we can. The count and redirection do work.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There is usually a line terminator at the end of the output of each operating system command. It's this that puts the cursor on the next line when output is to screen.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.