SHELLSCRIPTEXITZERO custom statement

I have a custom statement called SHELLSCRIPTEXITZERO. I didn’t write it, but believe it came from Jim or Panorama documentation.
The description is:

  <DESCRIPTION>
  This statement executes a UNIX shell script. It appends {; 0} to the end of the source code in order to cover applescript errors when the shell script fails and exits with a non zero status.
  This statement is designed to replace the older EXECUTEUNIX and EXECUTESUDOUNIX statements (which are retained for compatibility with older databases).
  </DESCRIPTION>

Whe checking it, it contains the ‘unknown’ statement, executewinshell, which I can’t find documentation on. I assume it’s part of the Unix script, but it throws the error in the procedure window.

Is anyone familiar with this procedure who can tell me if it can be used in Panorama X? The heating system software uses it to open and quit the Terminal app.

retryloopaction “shellscriptexitzero ||| killall Terminal |||,shellResult,10,sysP ”,{if info("error") notcontains "No matching processes were found" sendoneemail "",adminEmail,"Error launching QuitTerminal.app, .Terminal",info("error")+¶+"-----"+¶+shellResult endif},4
if shellResult≠""
    sendoneemail "",adminEmail,"Error quitting Terminal, .Terminal",info("error")+¶+"-----"+¶+shellResult
endif

Do I need to replace it with the shellscript statement?

Thanks,
Jeff

I don’t have any recollection of writing such a custom statement. In fact, I don’t recall ever writing any custom statement for anyone, ever.

Part of the description you supplied comes from the SHELLSCRIPT statement. So I think someone took the Panorama 6 version of the SHELLSCRIPT statement and modified it to produce the custom statement you have. But that wasn’t me, so I have no idea what is in your version, what it does, or why it is needed in your code.

I think that the executewinshell is for executing scripts on Windows. Since Panorama no longer runs on Windows, that statement doesn’t exist.

Probably a better question is - why. the heck are you opening and quitting Terminal.app? If you really need to do that, Panorama X has support for running a shell script in a terminal window.

I would think, however, that you shouldn’t be messing with Terminal.app at all. You should probably back up and take a fresh look at your application, rather than trying to convert the old code line by line. That’s usually not necessary when converting from Panorama 6 to X, but this isn’t really Panorama code - you’re scripting the operating system itself. So naturally it’s all different.

Hi Jim,

Thanks, I had missed that that section was related to Windows and deleted it.

I have several Terminal scripts that run constantly in the background to read data from the 1-Wire Servers that are polling various temperature and flow sensors, then write it to text files that I convert to meaningful data. If these scripts hang up and stop updating, I use the statement to quit the terminal and then reopen it to start the scripts fresh.

Jeff

This is why it is always better to explain what your actual goal is. You’re going to get huge benefits by rewriting this section of code. Panorama X can do everything you want it to do all by itself, there’s no need to use Terminal.app. This will make your application much cleaner and way more bulletproof. To find out how, search the Panorama help for posixtask.

In fact, if you wanted to, you could make your own version of Terminal.app right inside a Panorama form. That’s what I do when I build a new version of Panorama - using shell scripts to compile, link, notarize and upload PanoramaX.app. It all happens in the background, but with live updates displaying the progress in a Panorama form.

What is involved in reading the data? Is there a custom shell script? Or are you using something like curl to access the data via http? If the latter, I would suggest possibly doing this directly using the urltask( function, which also runs in the background. You could do this in combination with a timer.

Hi Jim,

Thanks for all the questions. They have got me questioning why I went with using the low-level Telnet connection to the 1-wire servers in the beginning. I should be able to get all the data I need directly from the server’s outputted xml files. I can use urltask( or loadurl( to access that. I think I’ll be able to eliminate using the Terminal, in or outside of Panorama. In the case of the temperature sensors, I can totally eliminate the conversion from the raw data, as the xml file already has the converted output.

Thanks,
Jeff

1 Like

Sounds like a good plan!

Instead of loadurl(, I would use url( for new applications. There’s nothing wrong with loadurl(, but url( is more flexible (basically url( is a superset of loadurl(, they both use the same network code underneath). Basically urltask( and url( are the same, except that urltask( is asynchronous (runs in background) and url( is synchronous. I suspect your server responds very quickly so probably url( is fine, it is a bit more complex to write asynchronous code.