niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
trying to test output msg in terminal with applescript
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
martin
*nix forums beginner


Joined: 22 Feb 2005
Posts: 44

PostPosted: Tue Feb 08, 2005 10:39 am    Post subject: Re: trying to test output msg in terminal with applescript Reply with quote

I'm sorry you think i'm wasting your time and in the wrong place. I
thought I said in every post that I was looking for advice on building
unix code that I could place inside an applescript... which would then,
send the unix code to the terminal to automate terminal -through an
applet. after re-reading my posts, i realize that i probably could
have gotten to the point faster - and that i waited to say anything
about unix until the end of the post...but i did say:

"i would really have preferred to have a unix command that could check
for the output of the compiler message before it's actually generated
so that the next command could flow smoothly. i'm sure the unix gurus
here might know somehting that would help make this possible. "

and

"but my question wasn't to do with getting help with applescript. i'm

looking for advice on the unix portion of my problem."

I'm sorry for the confusion.
martin
Back to top
Robert Bonomi
*nix forums Guru Wannabe


Joined: 23 Mar 2005
Posts: 175

PostPosted: Tue Feb 08, 2005 3:11 am    Post subject: Re: trying to test output msg in terminal with applescript Reply with quote

In article <1107810831.681007.118700@c13g2000cwb.googlegroups.com>,
martin <ultragrimsocialmen@yahoo.com> wrote:
Quote:
but my question wasn't to do with getting help with applescript. i'm
looking for advice on the unix portion of my problem.
so, i'd still appreciate your time on this one if possible. - i'm not
looking to "make" or compile things - that's already taken care of.
i'm looking to check for the existance of text in the compile message,
and then process several alternative courses of action wtihin an
if/then script.

*IN*WHAT*LANGUAGE* is this "if/then script" where you want to check for
the 'existence of text in the compile message' written?

Based on your original message, it appears that the language _is_ 'applescript'.
You need to go to an appropriate group for _that_ language. 'comp.unix.shell'
is *not* such. The vast majority of people that frequent *this* group will
not know anything about applescript syntax or coding applescript scripts.

Generically, there are two approaches to your problem:
1) a 'chained' set of 'if-then-else' constructs,
e.g.:
if (pattern1 in string) then
thing1
else if (pattern2 in string) then
thing2
else if (pattern3 in string) then
thing3
else if (pattern4 in string) then
thing4
else
echo No Match Found.
endif

2) some sort of a 'multi-way branch' command
e.g.:
case string in
pattern1) thing1
;;
pattern2) thing2
;;
pattern3) thing3
;;
pattern4) thing4
;;
*) echo No Match Found.
;;
esac
Back to top
martin
*nix forums beginner


Joined: 22 Feb 2005
Posts: 44

PostPosted: Mon Feb 07, 2005 8:13 pm    Post subject: Re: trying to test output msg in terminal with applescript Reply with quote

but my question wasn't to do with getting help with applescript. i'm
looking for advice on the unix portion of my problem.
so, i'd still appreciate your time on this one if possible. - i'm not
looking to "make" or compile things - that's already taken care of.
i'm looking to check for the existance of text in the compile message,
and then process several alternative courses of action wtihin an
if/then script.
..
martin
Back to top
Bill Marcum
*nix forums Guru


Joined: 28 Mar 2005
Posts: 1264

PostPosted: Mon Feb 07, 2005 6:08 am    Post subject: Re: trying to test output msg in terminal with applescript Reply with quote

On 6 Feb 2005 08:27:01 -0800, martin
<ultragrimsocialmen@yahoo.com> wrote:
Quote:
i'm working on an applescript that, when activated by the user dropping
their
source code file on the droplet icon, will automatically run several
compile
commands through terminal. (note: this app is meant to automate using

For help with applescript, you might try a comp.sys.apple.* newsgroup,

but if you are compiling something, perhaps you should be using make.
Back to top
martin
*nix forums beginner


Joined: 22 Feb 2005
Posts: 44

PostPosted: Sun Feb 06, 2005 3:27 pm    Post subject: trying to test output msg in terminal with applescript Reply with quote

i'm working on an applescript that, when activated by the user dropping
their
source code file on the droplet icon, will automatically run several
compile
commands through terminal. (note: this app is meant to automate using

terminal for people who don't want to mess with it).
--i'm new to applescript - but very new to unix and I need some help
to figure out
how to - or if it's possible to do several things, which I'll describe
below.

I've included my applescript code below, with comments "--" so if
anyone out there
knows applescript, you might be able to see what's going on - if not,
i'll summarize the
work flow that i'm trying to accomplish.

the first steps are all coded to work properly now - the user drags
their source code
file and drops it on the applescript droplet. that collects
information about the path to
the source code file - gets the name of the source code file, and
location of it's directory...
then goes to the terminal, opens a new window/shell, titles it "alan
compiler window" (alan
is the programming language) and runs through changing directories to
the working directory.
then tries to issue a command to compile the sourccode file.

at this point, i've been playing around trying to figure out the best
alternative for checking the
compiler output message so that the app can then determine what to do
next. in the event of a
successful compile messages, which will look like:
"No warnings or errors detected.
1 informational message(s)."
i want to the app to automatically continue business and issue a run
command, which will
open the compiled program in the terminal window (it's a text based
game programming lang
which uses the terminal to play/test the game).

BUT, if the compile fails, the output message isn't so clean...it'll
put out something like:
"titleofsourcecodefile.alan
74. OBJECT ATTRIBUTES
=====> 1
*1* 102 E : Syntax error. Attempting to repair by ignoring
"Identifier
'ATTRIBUTES' Identifier '.' Identifier ..."."

in other words, i think it'll be more consistant/simple to just check
to see if the successful compile message
exists - if not, output the failed compile message to a text file, open
the file, and allow the user
time to debug before running through the whole process again.


here's what i have so far - (and you can see that I've opted for an
(easier) fix to the problem by having terminal first output a text
file , and
have finder check for the existance of certain text...) but even that
isn't
working. (( with the code as is, i'm getting a "can't get file
<pathname> as an integer"
error))

i would really have preferred to have a unix command that could check
for the output of the compiler
message before it's actually generated so that the next command could
flow smoothly.
i'm sure the unix gurus here might know somehting that would help make
this possible.

thank you so much
(applescript below)

on open {alan_source}


global current_location
global path_minus_root
global cd_path --"cd "
global source_file_name --"nameofsourcecodefile"
global dot_alan --".alan" (extension only)
global source_file_name_dot_alan --"nameofsourcecodefile.alan"
global dot_slash_alan -- "./alan "
global output_compiler_results -- " >alan_output.txt" make results
write to txt file
global alan_compiler --"./alan nameofsourcecodefile.alan >
alan_output.txt"


tell application "Finder"
set current_location to folder of (path to me) as text
set path_minus_root to POSIX path of current_location as
text
set cd_path to "cd " & path_minus_root as text
if kind of alan_source is "folder" then
display dialog "This helper app will only
accept you¬
dropping a single source_code.alan file.
Please
re-try."
--needs button here as killswitch to halt
program, else error msgs
for user...
else
set source_file_name_dot_alan to the displayed
name of alan_source
--source_file_name_dot_alan is now the
complete file name w/
extension.
end if
set dot_slash_alan to "./alan "
set output_compiler_results to " >alan_output.txt"
set alan_compiler to¬
dot_slash_alan & source_file_name_dot_alan &
output_compiler_results
end tell


--need a variable to hold address of new "alan_output.txt"
file.
global path_to_output_text_file
set path_to_output_text_file to path_minus_root &
"alan_output.txt"


tell application "Terminal"
do script cd_path
set custom title of front window to "Alan
compiler window"
close the back window
delay 2
do script alan_compiler in window "Alan
compiler window"
end tell


tell application "TextEdit" --textedit opens but code breaks at this
point
open path_to_output_text_file in window
say "x" --doesn't say "x" - only error msg:can't get
file as
integer"
try
beep1 --doesn't beep
if it contains ("No warnings" as text) then
display dialog "this works! found the words"
--msg for testing only
beep 3 --doesn't beep
else
display dialog "didn't find
anything that way." --msg for testing
only
end if
end try
end tell


end open


thank you again
Martin
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 12:01 am | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts test admin Atest 0 Mon May 14, 2007 6:29 am
No new posts mailq output format bacilko1 Postfix 0 Tue Oct 03, 2006 12:34 pm
No new posts Python proficiency test Kent Johnson python 0 Fri Jul 21, 2006 10:47 am
No new posts someone using apmd on ppc please test patch for #222635 Aníbal Monsalve Salazar devel 1 Thu Jul 20, 2006 11:50 pm
No new posts syslog Output Change Maja AIX 0 Thu Jul 20, 2006 8:41 pm

Debt Consolidation | Pacotes Reveillon Salvador | Guitar Lesson | Loans | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 2.4582s ][ Queries: 20 (2.3561s) ][ GZIP on - Debug on ]