Help in Applescript?
Hey guys I really need help here...
I've been trying to write an applescript to login my college account.
I got pass the sign in part but im stuck on figuring out how to click a certain button on the webpage.
Did a little research and found that it was either UI scripting that I should use or java command.
But im on OSX Maverix and I can't figure out how to enable UI scripting and how to use it (in doesn't show in the accessibility list)
And for the java commands, I know how to find the source code of a page but i can't figure out how to find the button code, and how to write the script... Any help would be appreciated thank you!
So far thats my script:
set thePassword to *password*
set theID to *IDnumb*
tell application "Safari"
Activate
Open Location *Website*
delay 5
keystroke ID
keystroke tab
keystroke password
keystroke return
delay 2
End tell
Here is how I navigate these two panels. First, I click on the vnc icon. I then curser down to to the line "Connect to Listening VNC Viewer...". Press return. Type in ip address. Press return.
first part clicks on vnc icon.
move mouse and click mouse are not standard. They are an applescript addon see comment below. Do not know if available with mavericks.
For you situations you probably do not have to click on the button. Use the tab to move to the button you wish to click. Press return. ( keystroke return )
log " --- Starting on " & ((current date) as string) & " --- "
-- Go after screen resolution
do shell script "/usr/sbin/system_profiler SPDisplaysDataType | grep 'Resolution'" -- get info
tell the result to set {DisplayWidth, DisplayHeight} to {word 2, word 4} -- get resolution
if DisplayWidth = 800 then
(move mouse {474, 14})
else
(move mouse {698, 11})
end if
click mouse
tell application "System Events"
repeat 6 times
key code 125 -- cursor down key code 125
delay 1
end repeat
delay 2
keystroke return
delay 3
keystroke "192.168.0.101:5900"
-- if you went to press return after typing the password
delay 3
keystroke return
-- incase we get an error message. should probably be ok, in good case.
delay 3
keystroke return
end tell
First, there is the XTools scripting addition, which will give AppleScript the ability to move the mouse.
http://www.lestang.org/osax/XTool/
XTool-2.0.dmg.tgz
Installation :
Drag XTool.osax from insite the image to one of the following locations (create the directory if it does not exist) :
a : ~/Library/ScriptingAdditions/
b : /Library/ScriptingAdditions/
c : /System/Library/ScriptingAdditions/
I have it in directory /System/Library/ScriptingAdditions/
My other two directories do not exit: ~/Library/ScriptingAdditions/ &
/Library/ScriptingAdditions/
. Next, you will need to place a script application into your login items (System Preferences > Accounts > Login Items) that will move the mouse when you log in:
Similar Messages
-
Help creating applescript to select email data and insert in existing Excel workbook
Hi there
I'd really appreciate some help.
I want to select three types of data, specifically Name, Email address, and a Date, from the body text of emails in Mac Mail, and export them into columns in an existing Excel workbook.
I've set up a rule in Mail based on the sender, and specified an Applescript action based on the script below. I've sent test emails to meet the rule conditions, and included in the body of these emails the text items below to trigger the script rules, but the Applescript doesn't do anything.
Where I am going wrong?
using terms from application "Mail"
on perform mail action with messages theMessages for rule TravelRule
tell application "Mail"
repeat with each_message in theIncomingMessages
-- reset the variables
set thetext to content of each_message
display dialog thetext
set {thename, theemail, thedates} to {"", "", "", ""}
-- get the message text
set message_text to content of each_message
-- setup text item delimiters
set {old_delims, my text item delimiters} to {my text item delimiters, ": "}
-- iterate through the lines of the message looking for the keywords
repeat with each_para in (paragraphs of message_text)
if text item 1 of each_para = "Name" then
set thename to text item 2 of each_para
else if text item 1 of each_para = "Email" then
set theemail to text item 2 of each_para
else if text item 1 of each_para = "Dates" then
set thedates to text item 2 of each_para
end if
end repeat -- each para
set my text item delimiters to old_delims
end repeat -- each_message
tell application "Microsoft Excel"
activate
open workbook "/PathDetailsHere/Workbook1.xls"
set formula of range "G6" of worksheet "sheet1" to thename
set formula of range "G9" of worksheet "sheet1" to theemail
set formula of range "G12" of worksheet "sheet1" to thedates
end tell
end tell -- application "Mail"
end perform mail action with messages
end using terms from
I'm a complete Applescript newbie, so any help would be really appreciated! Thank you.my variables are global for all data providers since I use the same query for my data providers.
It's just the values (some of them : ex: conso version) that differ from one data provider to another.
ex : here for 2 diff Data providers based on the same query i need to enter the following values for mandatory variables
Different versions / different years but same conso group / data entry year/ posting period.
i would like to have the possibility to enter these values out of the "select values for variable" window (not convenient when we have 7 or 8 DP...), but directly in the workbook.
But maybe this is not possible...
In DP1
conso version = A_PL
conso group = FR01
data entry year = 9999
fiscal year = 2010
Posting period = 12
In DP2
Conso version = P4_MAG
Conso group = FR01
Data entry year = 9999
fiscal year =2011
Posting period = 12 -
Help with Applescript and Admin Privelages
I just started using Applestript a few months ago and I can't figure out how to give my script Admin rights. Basically, it turns on and off my internet sharing and file sharing through dialog boxes. I copied and pasted the whole code below if you want to test it, but this is the part that is giving me trouble. There are 4 lines similar to this, the actions that turn on or off the services.
do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
I've tried adding "with password _____" and "password_____" but neither worked. Can anyone help me make this script authenticate itself so I don't need to keep typine in my password? I could easily make a keystroke in system events to type it in but it doesn't always ask for it so I don't know how I'd make the script know when it needs to enter the password. any help is much appreciated!
Some things to clarify: The first shell script is there to invoke the "authentication" dialog so I can sign in once I launch the app and get right into the settings. However, I'd like to make it so the script doesn't even need admin permission to run, or make it somehow have my password built in to it. Security is not an issue, its my personal computer that nobody else has access to so I really don't care if my password is written in the code. Also, if you have any tips on how to streamline the Quit/Hide/Resume dialog I'd appreciate that too. Resume is there because there's a chance I won't have to sign in again if the app does not quit, however more often than not I have to sign in anyways. Thanks again in advance, sorry this post is so long but like I said, I'm pretty new to all this so I don't know exactly what you need to be able to help me.
The Whole Script:
-- Variables and Authentication
set done to "n"
set quitapp to "no"
display dialog "Please enter your password to allow Sharing Manager to make changes to your settings." with icon caution
do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
delay 0.2
-- Repeats
repeat while quitapp is "no"
repeat while done is "n"
-- Choose Setting
display dialog "Choose Setting to Edit" buttons {"Internet", "File Sharing", "Exit"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Internet" then
-- Commands for Internet Settings
display dialog "Internet Sharing" buttons {"On", "Off", "Cancel"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "On" then
do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
else if the button_pressed is "Off" then
do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
end if
else if the button_pressed is "File Sharing" then
-- Commands for Sharing Settings
display dialog "File Sharing" buttons {"On", "Off", "Cancel"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "On" then
do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
else if the button_pressed is "Off" then
do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
end if
else
set done to ""
end if
end repeat
-- Confirm Quit/Hide
display dialog "Really quit? You will have to reenter admin info next time." buttons {"Quit", "Hide", "Resume"} default button 1
if the button returned of the result is "Quit" then
set quitapp to ""
else if the button returned of the result is "Hide" then
tell application "System Events"
keystroke "h" using command down
end tell
else
set done to "n"
set quitapp to "no"
end if
end repeatwith respect to general improvements, a couple of points:
If I'm reading this script correctly, it looks like you're putting up an applescript alert and leaving it hanging until it's dismissed. This is an atypical approach (applescripts aren't really meant to hang around indefinitely waiting for a respons). If I were doing this I would either go whole-hog and create an applescript application in XCode with a proper interface, or remove the hanging dialog and create a set of toggle scripts that I could use from the script menu. if you really want to keep the hanging dialog, though, you can streamline it by absorbing the secondary dialogs into the main dialog. that's like so:
set netSharingStatus to checkService("com.apple.InternetSharing")
set fileSharingStatus to checkService("com.apple.AppleFileServer")
display alert "Current Settings" message "Click to change settings" buttons {"Internet " & netSharingStatus, "File Sharing " & fileSharingStatus, "Exit"} default button 3
-- choose next action based on the button clicked and the status vairable
on checkService(service)
do shell script "launchctl list"
if the result contains service then
return "On"
else
return "Off"
end if
end checkService
using handlers like the above can also streamline the rest of your script. the following construction means you only have to write the do shell script line once, rather than the four times you currently do, and makes for much cleaner reading.
if the button_pressed starts with "Internet" then
toggleService("com.apple.InternetSharing", netSharingStatus)
else if the button_pressed starts with "File Sharing" then
toggleService("com.apple.AppleFileServer", fileSharingStatus)
else
--exit routine
end if
on toggleService(service, currentState)
if currentState in "On" then
set action to "unload"
else
set action to "load"
end if
set command to "/bin/launchctl " & action & " -w /System/Library/LaunchDaemons/" & service & ".plist"
do shell script command user name "adminusername" password "password" with administrator privileges
end toggleService -
Apple Script: I got this applescript off of a forum for RapidCart for Rapidweaver. It allows the user to upload multiple thumbnails to each e-commerce page with the code...I don't know how to make this work for my files tho...can anyone help...this is what the person said to put into applescript and then run it...please help...
display dialog "Item número" default answer "" buttons {"OK"} default button 1
set numitem to text returned of the result
display dialog "Número de fotos" default answer "2" buttons {"OK"} default button 1
set contador to text returned of the result
tell application "TextEdit"
activate
make new document
repeat with counter from 1 to contador
if counter = 1 then
make new word at end of text of document 1 with data "<a href=%resource(Labe/L" & numitem & ".jpg)% rel=\"remooz\" title=\"Ref. L" & numitem & " foto " & counter & "\"><img class=\"imageStyle\" alt=\"\" src=%resource(Labe/L" & numitem & ".jpg)% width=\"40\" height=\"40\"></a>" & return
else
make new word at end of text of document 1 with data "<a href=%resource(Labe/L" & numitem & "_0" & counter & ".jpg)% rel=\"remooz\" title=\"Ref. L" & numitem & " foto " & counter & "\"><img class=\"imageStyle\" alt=\"\" src=%resource(Labe/L" & numitem & "_0" & counter & ".jpg)% width=\"40\" height=\"40\"></a>" & return
end if
set counter to counter + 1
end repeat
end tellFirst of all, I know nothing about RapidCart, RapidWeaver
I've cut and pasted the script into the Applescript editor, compiled it and ran it
the first dialog prompts for "Item number" - so I typed "5"
the second dialog prompts for "Number of Photos" - so I typed "2"
Here's the output
<a href=%resource(Labe/L5.jpg)% rel="remooz" title="Ref. L5 foto 1"><img class="imageStyle" alt="" src=%resource(Labe/L5.jpg)% width="40" height="40"></a>
<a href=%resource(Labe/L5_02.jpg)% rel="remooz" title="Ref. L5 foto 2"><img class="imageStyle" alt="" src=%resource(Labe/L5_02.jpg)% width="40" height="40"></a>
the generated HTML is meaningful to RapidCart.
Now, the author should have explained that this script is specific to his needs and MUST be customized for your use.
I don't know how familiar you are with HTML but the "resource" tag refers to a file - a jpg file in this case. -
Help with applescript to quit certain processes by name?
Hey, for anyone who knows how to program applescripts well, I could use some help with the script below.
I'm very new to applescripting and I'm trying to write a script that would automatically quit up to 100 instances of the Google Chrome Renderer process.
Thanks to google, I found a script similar to what I wanted, and after some tinkering I thought I had it just right. The thing is, if I only set the app_name to Google Chrome, it quits Chrome just fine, but when I try it like this, it doesn't receive any data from grep or awk.
If anyone can help I'd really appreciate it.
repeat 100 times
set app_name to "Google Chrome Renderer"
set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
set new_pid to first word of the_pid
try
if new_pid is not "0" or "1" then do shell script ("kill -9 " & new_pid)
end try
end repeattry this:
tell application "System Events"
set procs to (every process whose name is "Google Chrome Renderer")
if (count of procs) > 100 then
set max to 100
else
set max to count of procs
end if
repeat with i from 1 to max
tell (item i of procs) to quit
end repeat
end tell -
Help with Applescript - filenames
Hi!
I hope there is someone who can help me. I have very little experience with Applescript, and have spent a couple of days scouring these forums amongst others without any luck...
I have a folder (titled XLS) with about 1000 excel files in it. They are numbered basen on some parametric calculations (1111.xls, 1112.xls, 1113.xls, etc). I have constructed an Automator rutine which, one at a time, can open each excel file, copy some cells and then paste the data into an empty xml-file in TextWrangler. The empty xml-file is also in the XLS folder.
What I am looking for is an applescript which can rename the open xml-file with the same filename as the xls-file. So, when 1111.xls is open, the xml-file gets renamed 1111-xml; when 1112.xls is open, the xml-file gets renamed 1112-xml, etc. Each new xlm-file is to be saved into a folder XLM, whivh is also in the XLS folder.
Thanks in advance....
RobSe below; there are two folders on the desktop; "xls" (with xls-files in) and "xml", as well as the empty Template.xml file. Here it is!:
--3 XLS to XML
tell application "Finder"
set fileList to every file of entire contents of ("YourHD:Users:You:Desktop:xls" as alias)
end tell
repeat with i from 1 to number of items in fileList
set currentFile to (item i of fileList)
tell application "Microsoft Excel"
set screen updating to false
open currentFile
activate currentFile
activate object worksheet 1
copy range range ("YourRange")
end tell
tell application "Finder"
copy file "YourHD:Users:You:Desktop:Template.xml" to folder "YourHD:Users:You:Desktop:xml"
end tell
tell application "Microsoft Excel"
set docName to name of window 1
end tell
tell application "Finder"
set docName2 to text 1 thru ((offset of "." in docName) - 1) of docName
set theFile to "YourHD:Users:You:Desktop:xml:Template.xml" as alias
set the name of theFile to docName2 & ".xml"
open file theFile
end tell
tell application "TextWrangler"
activate
paste
close text document 1 saving yes
end tell
tell application "Microsoft Excel"
activate
close active workbook saving no
end tell
end repeat
tell application "Microsoft Excel"
set screen updating to true
quit
end tell
tell application "TextWrangler"
quit
end tell -
Hi there, thanks in advance for any help on this ...
I have an excel spreadsheet export from our back-office that exports product information from our shop. I want this to be reformatted slightly using AppleScript
An example of our workbook is as follows
A1 B1 C1 D1 E1 F1 G1 H1 I1
text text
So essentially columns A1 to G1 are blank.
What I would like is Applescript to add a row to the top of this workbook and pre-fill each column with a column heading. These are always the same regardless.
Then I would like Applescript to pre-fill each blank row with pre-set information. For example (now) A2 until the last row would read "New". Each one of the blank columns has different data but its always text, never a formula. Ideally it should only fill the rows where H1 contains text, so it does not continue filling those empty columns with data when the rest of the sheet is blank.
Then (if possible) it should save this as a comma delimited CSV.
I know this is pretty harsh, but it would save me hours and hours and work.
Thanks!applescript forum is under OS X technologies.
http://discussions.apple.com/forum.jspa?forumID=724
btw, was it you I had a long thread with about moving pictures around using applescript? I lost track of that... -
Need help modifying Applescript to copy "Spotlight Comments" into file
Hello all,
I have a very large batch of images of Leonardo da Vinci's notebooks. I used the "Spotlight Comments" field of each file to save information about the notebook page depicted in each image:
Well, I had to modify each image in Photoshop and when I saved the files, Photoshop of course didn't retain the Spotlight Comments. Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals), or at least copy the text from the Spotlight Comments field of the original files and paste each block of text into a txt file with a couple of blank lines in between each entry, so that I can manually copy/paste the citations into the modified image's Spotlight Comments fields.
I successfully used this Applescript: https://discussions.apple.com/message/6741062#6741062
to get the Spotlight Comments from the original files, but it displays them one by one in pop-up dialog boxes and because I have almost a thousand images it is extraordinarily wearisome to copy the text from each pop-up, paste it into a text file, make two blank lines, click "OK" in the pop-up to get the next one...
Can anyone suggest how I can modify the code I have to tell the Finder to copy the contents of each pop-up and paste them into a single text file with a couple of blank lines between each entry?
I have the barest, most rudimentary knowledge of Applescript, which is why I'm asking if one of the wizards here can help me modify or write an Applescript to do what I need to do.
Thank you so much!
BTW, here is the code from the aforementioned discussion that gets the Spotlight Comments from files. I made into an Applescript application using Automator:
tell application "Finder"
repeat with tItem in input
set (comment of tItem) to (text returned) of (display dialog "Spotlight Comment: " default answer (comment of tItem as string))
end repeat
end tellHi,
Evan Izer wrote:
Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals)
This script does exactly that:
set sFolder to (choose folder "Select folder wich contains original images.") as string
set dFolder to choose folder "Select folder wich contains modified images."
tell application "Finder"
repeat with tItem in (get document files of dFolder)
set origFile to sFolder & (get name of tItem)
if file origFile exists then
set origComment to comment of file origFile
set comment of tItem to origComment
end if
end repeat
end tell -
Help with AppleScript for Numbers - please!
I posted a question on the AppleScript section, if anyone can help...
https://discussions.apple.com/thread/3451760
Thanks!
(I'm trying to get an array into what I know of in Excel as a "range". How can this be done with numbers?)Does this help? This would work if tagValues in your script is a single value.
tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
set selection range to range "B2:D5"
set tagvalues to 1
set value of cell in selection range to tagvalues
end tell
If tagValues is a list, you may have to set each cell separately, indexing through each value in tagValues. -
Help with AppleScript/ Automator Code
I am an intern at an architecture firm, and I would like to know if there is any way to code a program (using AppleScript or Automator) to complete this task:
Combine files that have similar file names into a folder and rename the file as the first file automatically. There are hundreds of files, and an expedient and efficient way of completing this task would be greatly appreciated.
For example:
I have files:
07-480-1.jpg
07-480-2.jpg
07-480-3.jpg
07-480-4.jpg
07-481-1.jpg
07-481-2.jpg
07-481-3.jpg
07-481-4.jpg
07-481-5.jpg
I want to select files names with similar characters (07-480 and 07-481) and place them into respective folders.
So the folders would be called
07-480-1
07-481-1
Any advice would be helpful.
Thank You!
OSX 10.9.5Almost anything is possible... the issue is the work-effort required to achieve the desired result.
In this case there are a lot of variables that you haven't covered, which may make the job easier or harder.
For example, you give a series of example file names, and appear to want to group them by the same initial 6 characters (although your example seems to create folder names based on the first 8 characters of the first match... is that true? Without knowing the background, I would expect '07-480-1.jpg' to go into the '07-480' folder, not the '07-481-1' folder). Those kinds of details will make a difference.
So if my theory is correct ('07-480' should be the folder name), do you want to create a folder every time? or only when there are two or more files (e.g. do you want an '07-490' folder when there's only one relevant file?
Here's a starting point. I'm assuming that you want the '07-480' form of the folder. When the script runs it will ask for the folder to check, then (blindly) iterate through the files in that folder, moving them into folders based on the first 6 characters of the file name, making new folders as needed:
tell application "Finder"
set theFolder to (choose folder)
repeat with eachfile in (get files of theFolder)
-- assume the standard filename format
-- may need error checking here to make sure the name matches what we expect
-- for now we just skip over any errors through the use of a try statement
try
-- get the first 6 characters of the file name
set basename to characters 1 through 6 of (get name of eachfile) as text
-- check if we already have a folder of the desired name
if (not (exists folder basename of theFolder)) then
-- we don't, so make one
make new folder at theFolder with properties {name:basename}
end if
-- now move the file into the folder
move eachfile to folder basename of theFolder
end try
end repeat
end tell -
Hi i need help with applescript to stop downloads when vpn fails
I am an apple script novice, I would like to be able to have a script run all the time to detect vpn failures and close transmission when this happens:
so far:
on idle
do shell script "ifconfig -lu"
if "ifconfig -lu" contains "tun0" then
else if "ifconfig -lu" does not contain "tun0" then
tell application "System Events"
tell application "Transmission"
quit
end tell
end tell
end if
end idle
it closes transmission and nothing else. tun0 is my vpn interface and seemed the most fireproof way of understanding the state of the vpn connect. When VPN is down tun0 doesnt exist. Please help.
many thanksThere are several things wrong with your script.
First, the glaring one:
if "ifconfig -lu" contains "tun0" then
This will never, ever, ever be true. What you're asking AppleScript is whether the string "ifconfig -lu" contains the string "tun0". Never going to happen. Not even close.
What you really mean is whether the output of the shell command 'ifconfig -lu' contains 'tun0'. The easiest way to do that is to capture the output of the do shell script command in a variable and then test the variable, not the literal string:
set activeInterfaces to do shell script "ifconfig -lu"
if activeInterfaces does not contain "tun0" then
-- stuff goes here
end if
Now AppleScript runs the shell script and puts the result in activeInterfaces which you then test to see if it contains (or, in this case, does not contain) the string you're looking for.
Note that I've also reworked your if statement.. there's no need to have an empty 'if' clause followed by an else if that checks the opposite... by definition if the first one fails the second one will be true.
Also note that there's no need to tell System Events to tell another application to quit - you can just do that directly.
Next up is that you don't exit your own script after you quit Transmission. So now you have the scenario where the VPN drops, your script detects it and tells transmission to quit. However, your script keeps running so it then rechecks whether the tunnel is up... since it presumably isn't, it then relaunches Transmission in order to tell it to quit again. Then it rechecks whether the tunnel is up, if it isn't, it relaunches Transmission to tell it to quit... then it rechecks... you get the idea.
Ideally you should tell your own script to quit after Transmission has exited so that you're not stuck in this loop.
Lastly you don't include a return value in your idle handler. This means that your idle handler will run every 30 seconds. That might be good enough, or you might want to check more or less frequently. Just return a value indicating the number of seconds to pause between iterations - realise that the more frequently you check, of course, the more load you put on your system
Adding that all up you'll end up with something like:
on idle
set activeInterfaces to do shell script "ifconfig -lu"
if activeInterfaces does not contain "tun0" then
tell application "Transmission" to quit
tell me to quit
end if
return 30 -- 30 is default value, but it doesn't hurt to include it here
end idle -
Hello,
I am newbie to apple-script. I have a scenario, i have 15 apple PC's connected in a network. I need a applescript that i will be running from any one of the machines, well it should communicate with all the other machines and run system_profiler command in the respective terminals of the machines and should pull the output back to my machine where the applescript resides. The output of each apple machine should b stored in a file having its name as the hostname of the that respective machine. Output file can be a simple text file.
Please guide me on this. Help appreciated
Thanks
-Akshay Show can automate the process for the script so that it will read the several ip addresses of the target machines from the text file which would be residing in the same directory where the script is stored
You can read the contents of any file via something like:
set fileContents to read file "path:to:file.txt"
If you want a file relative to the script that will take a little extra work depending on how you save your script. If it's saved as a script application you should be able to use 'path to me' to find where the app is, and go from there. A simpler solution would be to store the file in a known location.
Once you've read the file you can break it into separate addresses. The best way depends on the specific format of the file. If you're using one address per line then you can simply:
set hostList to paragraphs of fileContents
now you have a list of addresses that you can iterate through:
repeat with eachHost in hostList
-- your code here
end repeat
Also, can write one more "tell.......end tell" code which would do a "eppc" back to my machine[the machine from which i would run the script] so that i can directly call the variable "sysProfile" and store its value into a file on my machine
I don't understand this statement. Assuming that you run the script from your machine, the data will be returned to your own machine, so you can just write the data locally. Just add the code that fetches the data within the repeat loop:
set fileContents to read file "path:to:file.txt"
set hostList to paragraphs of fileContents
repeat with eachHost in hostList
tell application "System Events" --of machine "eppc://<ip_addr_of_target_machine>/"
set sysProfile to do shell script "/usr/sbin/system_profiler -detailLevel full"
end tell
-- work out the filename
set outputFile to (path to desktop as text) & eachHost & ".txt"
-- open the file (create it if necessary
set f to open for access file outputFile with write permission
-- clear out the file (just in case)
set eof f to 0
-- write the data
write sysProfile to f
-- clean up
close access f
end repeat -
Help buttons Applescript studio
Hi everyone!
Well I learned a lot about the help menus since my last post:
http://discussions.apple.com/thread.jspa?threadID=686085&tstart=0
But I'm still stuck trying to get the help buttons that I installed on my interface to work. Specifically calling the help book is my problem. So if I have this connection in my script:
on clicked theObject
if name of theObject = "help button" then
-- here's where I want to call my help book to open in help viewer
end if
end clicked
I know there must be a simple command to open it, but all the documentation that I read it's not using the Applescript commands. The only "success" I've had is using some of these commands:
http://developer.apple.com/documentation/Carbon/Conceptual/ProvidingUserAssitApp leHelp/appendixb/chapter_7_section_1.html#//appleref/doc/uid/TP30000903-CH210-BGBBGBDC
But even if I can get it to work the viewer opens first the main Mac help page and then switches to my page. Sometimes it even shows my page with "Mac Help" as the title??? I know there's a simple command to this I just can't figure out what it is? Thanks in advance for your help!
RegI got it working!!! But some feedback would be great because here's what happened:
I started a brand new AS application just to check out the settings on a new project and I noticed that if I clicked the help menu it would display a dialog saying no help available. Now I didn't remember having that in my app and sure enough I was right. The difference is I started with a droplet form and I had to add in the help menu because the standard menu on a droplet doesn't have anything. But this added-in help menu that I put didn't display a dialog like the standard menu from the application template. And there is no help menu in the cocoa palette, you must just insert a menu item and make it into help. So I just copied the entire menu from the application template into my app and it worked right away! That's great but I just don't get exactly what the problem was? And hopefully not everyone that starts with a droplet template has the same problem??? :D:D:D
Thanks...Reg -
Help with AppleScript for outlook 2011
I wonder if anyone can help me with what I think should be a simply script.
I simply want to sweep(move) all of my incoming mail in Outlook to a specified IMAP folder.
Is this possible - it seems like it should be an easy script - if you get me started with the outline (for select all in incoming box and the move to an imap folder command) I think I can sort it.
Many thanks!
GordonI wrote a script to perform email-merges using Outlook or Mail/Address Book: https://github.com/craibuc/applescript-email-merge. Perhaps you will find it useful.
-
Help with Applescript: very basic functions
Hi guys, my first post. I'd very much like to switch from Excel to Numbers but not until I find an Applescript replacement for my stuff.
I wrote basic Excel Applescript just fine but I'm tearing my hair out just to perform simple scripts in Numbers!!!
Basically I need to do:
PART 1: Import External Data
- I think I got this covered, using a GUI copy script via the "System Events" application
- but since you guys are the experts: how do I make this process 'invisible'? i.e. each time the script runs, a Safari window appears. I don't want that to happen.
tell application "Safari"
activate
open location "http://www.whatever.htm"
end tell
tell application "System Events"
tell process "Safari"
keystroke "a" using command down
keystroke "c" using command down
end tell
end tell
PART 2: Paste It Into Numbers
- How hard can it be, right? Apparently I have the mental IQ of Gump I need Numbers to:
- clear data from an existing pre-defined/named table
- paste the data (from clipboard) onto this table (paste starting on cell A1), using the "Paste and Match Style" function
- hide certain columns <-- I realize if Numbers paste onto a table with hidden columns, it treats them as non-existent i.e. won't paste the same. Therefore I suppose before the paste script I'd need an unhide script
... and that's it!!
Help please I really hate Excel but can't move on till I figure this out... it's crucial to my livelihood.
Thank you all in advance!There is no paste function in the Numbers AppleScript's dictionary.
We may mimic it as I did during one year and a half with Numbers '08.
Go to my iDisk:
<http://idisk.me.com/koenigyvan-Public?view=web>
open the folder "For_iWork:iWork '08:for_Numbers:"
and download one of the items whose name starts with "paste".
This use of GUI scripting is interesting because it creates automatically rows/columns when required.
One draw back is the resulting font.
Yvan KOENIG (from FRANCE samedi 17 janvier 2009 21:12:52)
Maybe you are looking for
-
How can I add my custom ringtone to iTunes 10.7?
I recently got an iPhone 5 and I want to add a custom ringtone to it. I created a 29-second clip of a song using a software called Audacity and then saved it as an .m4r file. Then, I tried the drag-and-drop method to add the file to my Tones playlist
-
My hp pavilion dm-1 screen shows red,blue vertical line after switch it on
after switching on boot menu comes ,then the screen turns into a red blue vertical line.what should i do?
-
Updating picking qty from Shipment confirmation
Hi frenz, We got a requirement that when we get 856(shipment confirmation) from our external warehouse, we gotta update the picked quantities in delivery document and ASN has to be sent automatically. Can anyone help me on where to writ
-
Download driver on mac 10.7.4 for HP Laserjet 1000
just bought an HP Laserjet 1000 and getting error message that reads: installation for 10.6 or lower' and I have a MAC OS 10.7.4. how do I get the driver to load in?
-
HT201334 how I can delete entries or enrolled apps installed in my ipod touch?
I install a device enrollment challenge in my ipod touch but now i want to delete this.