Perhaps you can give me an example of how "set exitStatus to do shell script "command; echo $?" will ever have any result other than "0"?
Because my understanding is that everytime you call "do shell script" in AS, you get a fresh new & Unique shell to execute the command(s) that have no way of picking up where the last "do shell script" left off. Therefore I must be wrong in what I read because it would mean you could never get any result other than "0" with that command that I reffered to as useless. So please prove me wrong.
LeonieDF gave you an example, which you acknowledged.
The semicolon between the command the the "echo $?" allows more than one command to be executed in the same shell session. The shell saves the completion status of every command in the shell variable $?, the echo command it just sending the contents of $? to standard out (stdout), and the Applescript is putting the output from stdout into the exitStatus variable.
You could have a long serious commands separated by semicolons, vertical bar | pipe symbols, and they would all execute as part of the same shell session. You could even invoke a shell script that would be 1000's of lines long and it would be invoked in that shell session (along with subshells invoked by the initial shell session).
You are connect that each and every "do shell script" starts a new shell session. But you are wrong in that multiple commands issued in the same shell session start unrelated shells.
Am I hyjacking?
Yes in that you are taking control of this thread, but are unable to give any credit to anyone for information you find valuable. Then again, maybe you have not found anything valuable from any of the contributes answering your questions.
I came to this thread while looking for a method to read the terminal app output from within AS because "do shell script" cannot continue multiple commands from where the last "do shell script" left off. It does however make an easy single line shell that returns a clean result good for a one time only thing. Even for multiple commands on the same line, but not for functions that change depending on the output from the shell.
I have found the solution was to use terminal, and the problem was "do shell script" does not execute the same bash as terminal, nor can it continue where it left off.
But that was not necessarily what the original author, Hi], was asking for. The Hi] seemed to be satisfied with the answer given by John Maisey. Hi] gave John 10 points for his answer.
The last paragraph can be parsed 2 ways. a) the version of bash execute by the Terminal and by "do Shell Script" are different, and b) the Terminal is running a separate session from the session "Do Shell Script" invokes. a) would be wrong, in that it is the same bash program run by both, and b) would be correct in that the are running unrelated shell sessions.
You appear to want the ability to have co-processes where the process running the Applescript can interact with the process running the shell script. While this is possible, co-processes are more difficult to setup and control.
You approach was to have a Terminal session running one shell process and Applescript asking the Terminal session to read its display buffer.
My "hyjacking" was to correct the incorrect statements made by others so that other people who are trying to solve something and find this thread find the answer as well as know some of the information posted on this thread was dead wrong.
But you assume Hi] did not like his answer, and there is no evidence this is the case. You are trying to impose you view of this thread on Hi] and the users that posted answers that Hi] seemed to like.
If you have started your own thread, you could have defined the discussion by stating your needs, and not trying to alter Hi]'s request.
I am not looking for points, payment, kudos or political he-said-she-said.
Who said anything about you getting points. Then again, if Hi] wants to give you points, he is welcome, as he started the thread, and he is the one that gives out the points for this thread.
Any questions you asked (like how is it possible to get a non-zero status returned), you cannot give LeonieDF any credit for providing a solution. Only Hi] can do that. If you have started your own thread, you could have described your needs, and any useful information you received, you had the option to give that people giving those replies points (the only payment they get for donating their time and knowledge to this forum).
That is hijacking a thread.
Just correcting people that post pointless code such as the one you quoted me commenting on as being useless because it will always return "0" no matter what. Right?
Unfortunately you were not correcting the post.