Live input to a front-end for a shell script

This is really my first venture into AppleScript. I’m writing a GUI front-end to a shell script uninstaller for a program. The script will prompt the user for responses, and I need to know how I can send the contents of a text field to the script as responses to prompts.

Oh, and I also need some help with sending the output of the script to the scrolling text view I’ve defined in InterfaceBuilder. Here is the current code I’m using:

set contents of text view "outputTextField" of scroll view "outputTextField" of window "mainWindow" to shellScript

where shellScript is defined by

set shellScript to do shell script "/usr/local/bin/vpn_uninstall" with administrator privileges

Any help would be greatly appreciated.

To answer your first question, you can use a simple ‘display dialog’ command for getting information from the user via a single text field.

set myReply to text returned of (display dialog "Here is a question" default answer "Here is a reply")

As for your second question, well, what is your second question? Is the code you presented not working? Need more info here.

Instead of the output displaying in the text space I’ve assigned it, I get an AppleScript error window with the output which tells me that the script has canceled the uninstall.

And I’m not having any problems getting the input from the user; I’m wondering how I actually send that response to the script. Or is “myReply” some sort of predefined variable or something?

Well, what I did in the last post was both declare a variable and assign it a value of whatever the user input into the text field. All in one statement.

So, the result would be the variable ‘myReply’ which has a value of the text from said field.

Thanks for the feedback. I found another way to implement the uninstall that doesn’t require an interactive shell script, though. Now I’m having trouble hiding and showing text fields. I’m beginning the script with

set visible of text field cell "uninstalling" of window "mainWindow" to false,

so that when the user clicks the Uninstall button, the text will appear and then disappear after the process is complete. But it’s always visible in my application. Any ideas?

set visible of text field "uninstalling" of window "mainWindow" to false