Re: Scripting THROUGH terminal?
Re: Scripting THROUGH terminal?
- Subject: Re: Scripting THROUGH terminal?
- From: Dave Stewart <email@hidden>
- Date: Tue, 1 Oct 2002 17:37:24 -0700
The bear's in the details ...
What I'm trying to do is automate a procedure involving 4 separate
modules which process a store transfer. The business software we're
running (FACTS 7.1) is a character-based menu driven package. Most
users access this using dummy terminals at the sales counters, but a
few of us fortunate types use a terminal emulator on a Mac to access
the package by telneting to the AIX server and logging in. All 4
modules reside in the same menu page (Inventory Control / Warehouse
Transfers; we have a shortcut "IC3" which takes us here from any menu).
So ultimately I would want the script to :
1. [optional] Back out (using <F4>) of any module to a menu screen. I
haven't dealt with this part yet, I'm trying to start simply with the
assumption that the end user (our inventory control manager) can run
the script when he's at a menu (not in some module, which this option
would cover eventually if possible). :-)
2. Enter "IC3" at the menu prompt to get to the correct menu screen.
This is where I started yesterday, and where I find myself still stuck
today.
3. Enter "5" at the menu prompt to gain access to the first module
(Shipment Confirmation). After figuring out (2) this should be easy,
assuming I figure out how to do (2).
4. EITHER:
a) Allow the user to enter the desired data in the module itself,
remembering the user's inputs for use in the remaining 3 modules, OR
b) Prompt the user for the desired data PRIOR to performing these
steps and enter the desired data in the module.
5. Wait until the module finishes processing (a fixed time would be OK,
as long as it was long enough to ensure the module was done), send
another <F4> to back out to the menu screen and enter "6" to access the
next module.
6. Enter the user's data into this next module, wait for it to stop,
back out with a <F4> command, enter "6" for the next module ...
I haven't put to much thought into this yet, since I'm not sure it can
be done. I thought I'd start by trying to send the "IC3" command first
and see if I can get that command through to the FACTS package. I might
want to prompt the user for the desired data first, prior to loading
the first module, as it may not be possible (or at least ridiculously
difficult) to "save" the user's data while sending it through, but
that's a design issue I'll address when I figure out this is possible
in the first place.
Heavy details:
I'm running OSX Jaguar (10.2.1) with the August Developer updates
installed on a 450Mhz G3 tower (256MB ram). Terminal version is 1.3.1
(v82). The final end user would be running the same, except for the
Developer updates (unless needed for my script) and hardware (a 233Mhz
iMac instead of the tower; he's just not as cool as me:). We're
telneting to an IBM server running AIX version 4.3, which the user has
to log into. The .profile files for each user contains a script which
loads the FACTS 7.1 business software package, which the user also logs
into. After that FACTS login, there is no further logging in, unless
the session has timed out and FACTS has booted the user (shouldn't be
an issue with the desired script, since the user has to create the
store transfer before processing it; it's the processing part I'm
trying to automate).
When the FACTS package is running, we get a selection prompt at the
bottom center of the screen which we enter commands at (like the "IC3"
shortcut command I'm trying to get working). There is no buttons,
checkboxes or any other graphical components to deal with, it's a good
old fashioned text based menu system. The "snag" is getting script
commands through the terminal and to the good old fashioned text based
menu system on the other side. It seems like it should be easy (after
all, we're just typing stuff in the window), but it might not be
possible at all (unfortunate, but it just means I'm back to square 0
from square 1).
David, this will be quite a fun project, if I can only get it off the
ground (that's a BIG if, I understand that). My WebObjects project has
been a blast, once I understood how WO works (I created a corporate
website which allows the branch managers to keep track of maintenance
on their trucks. It accesses a FileMaker database using a custom java
class package. Tons of fun, but now I'm bald. LOL). My background
(short as it is) is mostly in Java, C and C++ development for Win
machines, I've only been on a Mac for less than a year now.
PS: You did catch the link to the AppleScript CGI, right?
(
http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.12.htm). I
would hate to think you have offered all this help and somehow missed
it.
Sorry for the length and thanks for your patience in reading it. Any
thoughts, insights or epiphanies would be greatly appreciated.
On Tuesday, October 1, 2002, at 04:08 PM, David A. Cox wrote:
Yup. I just did a little testing, and found the action I think you are
seeing.
You CAN target a window by the name of the window (such as the script I
sent as a sample), but it ONLY works if the terminal is at the command
line. You are looking to send commands to some intereactive application
(even if that application is just telnet).
Can you give us a little more info on exactly what you want to send?
Is it
a simple launch command, or are you looking to create some sort of
interface where different things can be sent? Does the thing have to
pause
for an authentication event (name and password by the person using it)?
Sorry I can't be of more help on this one. I have not had to send
things
to running applications before in the term. Sounds like fun though....
DAC
On Tue, 1 Oct 2002, Dave Stewart wrote:
On Tuesday, October 1, 2002, at 01:12 PM, David A. Cox wrote:
Did you try something like
tell application "Terminal"
do script "Command" in window "NAMEOFWINDOW"
end tell
You will need the """ marks in this to make it work.
an example would be:
tell application "Terminal"
do script "ps" in window "PSwindow"
end tell
Yeah, but what's the name of the window? I know it's title, the .term
file that created it, I can even get the window to show me the shell
it's running and it's tty (using the window settings), none of which
works, so how do I discern the window's name itself? I've tried a
number of things over the last day or so, but I just can't figure this
out. Keep in mind the script hasn't created the window, the window is
already running and I'm trying to "hook" into it with the script
(assuming that's possible). We start the window by double-clicking the
.term file we've created, which basically opens a terminal window and
performs the telnet command within it to connect to an AIX server,
which runs the business software.
Some else also suggested I access the window by number, ala
do script "ps" in window 1
but alas this also doesn't seem to hit my running window. It does
cause
another window (not a terminal) to pop up, titled "the result" which
contains a text area which simply contains a pair of empty quotes
(""),
but I have no idea what that means. Should that be telling me
something
(other than I'm lost)?
Other dazzling failures include:
--this failure causes a "variable windowname is not defined"
execution
error (?)
set windowname to window name
do script "IC3" in windowname
--this failure causes a NSCannotCreateScriptCommandError
set windowname to application name
do script "IC3" in windowname
"IC3" is a shortcut in the software we're running which takes us to a
particular menu, we would normally type in at the prompt (not a
standard *nix prompt, mind you, but a prompt from the software running
through the terminal. Does that matter? The cursor is guaranteed to be
there, we don't have to click anything to get it there). There are
probably half a dozen other similar things I've tried, inspired by the
Terminal Dictionary itself. Unfortunately the only thing I have gained
from it is a slightly elevated stress level. :-)
(Of course, all the above was inside a tell block)
By the way, where did you find instructions on "how to create a CGI
with
AppleScript" at? I am working on what I think is something similar,
and
your find might be of help.
Apple's AppleScript Resources (under "Essential Subroutines"). The
page
itself is at
http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.12.htm
Lots of good stuff in there, just nothing like what I'm doing. :-(
On Tue, 1 Oct 2002, Dave Stewart wrote:
Greetings list,
I am a newbie to AppleScript and am trying to automate a company
procedure. We are using (or starting to use) the Mac Terminal app
(in
Jaguar) as an emulator, using telnet to connect to the company
server
and running the business software through it.
I want to send commands through the OPENED terminal window to the
business software, but can't seem to figure out how to reference the
opened terminal. I can send commands to an unnamed window, which
causes
a new terminal window to be created, but that doesn't help much
(unless
I decide to try to create the telnet connection in that new window,
but
I already have the window running when I want the script to run.
Closing the window to run the script to reopen the connection seems
clumsy, especially since it's not me running the end product but
another company employee). How would I reference a terminal window
that's already opened on my desktop? We've set the title of the
window,
but that doesn't seem to do much good (or am I simply missing
something
important here?) We open the telnet connection using a .term file
we've
saved, but I don't see how that will help either. I could try using
the
tty of the process, but 1) that isn't working either and 2) I'm not
guaranteed to have the same tty from one day to the next, since the
window MAY BE closed after hours and restarted first thing in the
morning (not guaranteed, although the connection will be dropped
after
a timeout).
I've found docs detailing how to create a CGI with AppleScript,
surely
what I want to do is much easier than that?!? So what's the trick?
Thanking you all in advance for any help or insight,
Dave Stewart
Aqua-flo (Goleta)
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
Dave Stewart
Aqua-flo (Goleta)
email@hidden
Dave Stewart
Aqua-flo (Goleta)
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.