Product/components used and version/fix level are you on:
Natural (Linux)
Bash script (Linux)
Detailed explanation of the problem:
The issue is encountered with a Linux script that is being invoked by a Natural program via SHCMD. The script includes a menu and secondary level scripts, operates as expected when run directly in the Linux shell. However, it goes into infinite loop when called from the Natural program.
The Natural program calls this script via SHCMD and directs the output to a file, which is then read and displayed on the screen.
This works perfectly with scripts that are self-terminating. However, we’re encountering a problem with scripts that contain ‘read’ or ‘pause’ commands, which are typically found within loops.
It seems that the Natural process that calls the script is inadvertently issuing an ‘Enter’ signal causing the script to enter into an infinite loop, rather than pausing or waiting for input as expected. We need to find a way to prevent this from happening and ensure that the ‘read’ or ‘pause’ commands function as intended when the script is called from the Natural program.
Error messages / full error message screenshot / log fileL
The Natural program stalls as the called script is looping infinitely
Is your question related to the free trial, or to a production (customer) instance?
Natural product is licensed
Have you installed all the latest fixes for the products and systems you are using?
When using USR1052N, the Natural program still hangs, however, this time, a group of three processes is created for the script, while only a single record appears in the script output.
Termination of this hanging Natural session triggers the processes to build up the output as they did previously.
Otherwise, termination of these processes first causes Natural session to regain control and revert with an error message: 6390, indicating an
invalid work file name
Script snippet
VIEW=“”
while ! [ “$VIEW” = “q” ]
do
echo this is my test
pause
done
There is little difference between using CALL “SHCMD” or CALLNAT ‘USR1052N’. In both cases a shell is spawned, the shell executes while Natural waits for its completion, then Natural resumes execution. Any stdin the shell needs must be passed within your #cmd variable. Can you show us the contents of #cmd?
Please note that this may be true today, but it may no longer be true tomorrow, and there is no guarantee SHCMD will be there forever, USR1052N is the one and ONLY supported & documented method for this.
Could you kindly confirm whether the intermediate file is the sole method for displaying the output of the script within the Natural session that initiates this script?
Interface USR1052N supports the internal option STDOUT.
If STDOUT is set in the optional parameter CMD-OPTIONS, the command
output is returned in the optional parameter CMD-OUTPUT.
For reading the command output work file 10 is used.
I would like to express my sincere gratitude for everyone’ insightful feedback. Your contributions have been extremely helpful and are greatly appreciated. Thank you for your time and effort.