Sample Header Ad - 728x90

executing 2 scripts with connection

0 votes
1 answer
59 views
I've been given some challenge: there is an application that provides me some postfix expression and expects to get a solution within 5 seconds. If there is no solution, it quits, otherwise, it provides additional expression. The interface is like follow: etc. If there was only single expression I've thought to use tail -1 command to get the last line to get the expression and use the dc command to evaluate it. However, as there are unknown number of expressions (so far), I can't use it and have to do some loop till the string which is read is not starting with a number (i.e expression). Therefore I've though to use 2 scripts: 1. start the application always send text output to file1 and execute it in the background (script 1) 2. read the last row of a script the file1 (script 2), evaluate a solution and sent it to file2 (script 2) 3. read solution from file2, delete file2 (for next solutions), bring the application to foreground, send a solution and then send the application to background (script 1) However, it seems to be little bit complicate for me. Any suggestions how to simplify the procedure to solve it?
Asked by user1977050 (409 rep)
Jun 21, 2017, 08:33 AM
Last activity: Dec 30, 2018, 04:35 AM