System Interaction with SenseTalk

These commands and functions let your SenseTalk script interact with the system where the script is running, launch other programs, open files in other programs, or run system commands through the UNIX shell.

Open Command

Behavior: Starts another program, or opens a file with another program on the machine where your script is running. The most common use of this command is to open a file generated by the script, such as opening a text file in a text editor, or a tab-delimited file in a spreadsheet program, so the user can make further changes to it, print it out, etc. If the requested application is already running on the machine where the script is executing, it will be brought to the front, otherwise it will be launched.

Syntax:

open application

open file with application

Example:

open "iTunes"-- launch iTunes on this machine

Example:

open "/tmp/myFile" with "TextEdit"

Note: To open a file for reading or writing its contents within a script, use the open file command.

Shell Command and Function

Behavior: Runs a command in the command-line shell on the local machine and returns the output.

Syntax:

shell command {, optionalParameters}...

get shell( command {, optionalParameters}...)

Example:

shell "rm /tmp/testfile"

Example:

put shell("cd /; ls -l") into rootDirectoryList

Note: There is a Windows operating system limitation when running shell commands. When you run a shell command on Windows, you won't see any output from the shell command. To resolve this issue, redirect the output of the command by piping the output to a file. After the script completes, manually read the file contents to see the result.

shell "c:\windows\system32\cmd.exe", <</c "C:\Program Files (x86)\adt-bundle-windows-x86_64\sdk\platform-tools\adb" >> && MyCommand && "> someFile.txt"

put file "C:\wherever\someFile.txt"

Tech Talk

The shell command and function both set the result to the exit code of the command that ran. Typically the exit code is 0 when a command runs successfully and some other value when there is a problem, but the exact meaning of the exit code depends on the command that was run.

The command runs on the machine where the script is running. To run a shell command on another machine, you can use one of the shell commands that provides remote access, such as rsh or ssh.

Related Global Property

You can control the default shell application by using the shellCommand global property. For complete information about the initial default shells for each platform as well as how you can change the setting, see the shellCommand.

 

This topic was last updated on July 02, 2020, at 02:51:55 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2020 Eggplant