• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using Data From Tab Delimited Text File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Data From Tab Delimited Text File


  • Subject: Re: Using Data From Tab Delimited Text File
  • From: "Marc K. Myers" <email@hidden>
  • Date: Wed, 07 Nov 2001 11:45:44 -0500
  • Organization: [very little]

> Date: Wed, 07 Nov 2001 09:30:11 +1000
> Subject: Using Data From Tab Delimited Text File
> From: Les Cavanagh <email@hidden>
> To: <email@hidden>
>
> I need to write an Applescript to run a bunch of copies of Web Server Log
> Analysis Programs.
>
> The Web Server Log is broken up by a Perl script and files created in in
> folders corresponding to the domains hosted.
>
> The details of the domains hosted for the purposes of the Logging is kept in
> a Tab Delimited text file in the form:
>
> www.domain.com name_of_logfile
> www.domain2.com name_of_logfile2
>
> and so on...
>
> The name_of_logfile part is not important to the Applescript function, just
> the www.domain.com part as it will form part of the path to the application
> to be run.
>
> The path will be like:
>
> Macintosh HD:Web Server:Web Sites:server_stats:www.domain.com:Application
>
> So I want the script to go to the text file, get the first www.domain.com,
> activate the Application, wait till it is finished, then get the next
> www.domain.com from the text file and activate that Application and so on...
>
> The parts I am having trouble with are:
>
> 1. Getting the www.domin.com information from the text file
>
> 2. Getting the script to wait for the Application to finish before going on.

This (admittedly untested) code should resolve both your problems.
Please note that "[optn-L]" replaces the actual AppleScript continuation character:

set fileID to (open for access file "webLogFile")
try
set theText to (read fileID as {text} using delimiter {tab, return})
close access fileID
on error m number n
try
close access fileID
end try
display dialog "Error #" & (n as text) & return & m
end try
set appName to "nameOfTheApplication"
repeat with i from 1 to ((count theText) - 1) by 2
set filePath to "Macintosh HD:Web Server:Web Sites:server_stats:" & [optn-L]
((item i of theText) as text) & ":" & appName
tell application appName
tell application filePath
-- do stuff
end tell
end tell
repeat
delay 3
tell application "Finder" to set procList to name of the processes
if procList does not contain appName then
exit repeat
end if
end repeat
end repeat

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[11/7/01 11:44:27 AM]


  • Follow-Ups:
    • Re: Using Data From Tab Delimited Text File
      • From: Les Cavanagh <email@hidden>
  • Prev by Date: Re: attempting to count messages in Mail
  • Next by Date: CGI Request Query Part II
  • Previous by thread: Re: Using Data From Tab Delimited Text File
  • Next by thread: Re: Using Data From Tab Delimited Text File
  • Index(es):
    • Date
    • Thread