I’m trying to output multiple commands and multiple outputs in one text box. The script I have:
on clicked Install_button
set theCommand to "sudo ipfw list 2>&1"
set theResult to do shell script theCommand with administrator privileges
set the contents of text view 1 of scroll view 1 of window 1 to ("-----> " & theCommand & " >" & return & theResult)
end clicked
works great for ONE command, but I want many other commands (and their output) added to the contents of that text scroll box. If I add a new “set the contents…” I obliterate the previous results there. The processes will take some time (at least 20 minutes). If I just string the commands together, it leaves the user thinking that nothing is being done, and gives no clue to what is going on.
I get the impression that it can’t be done directly, but that I have to write it out to a log file and repeatedly re-“set the contents” to get it to update/refresh. Is there some way to use append (even though the append command looks like its meant for data cells in a table)? Or an “add to the contents” like command that I’m missing?
If I write it out to a log file, will I be able to set the color of text (cause I’m having problems with setting the color of Unicode text as well).
Just like in shells where you define me = me (+ you) and you have the new “me”. Should have remembered shell 101.
set the_initial_command to "ipfw list 2>&1"
set theResult to do shell script the_initial_command password the_admin_password with administrator privileges
set the contents of text view 1 of scroll view 1 of window 1 to ("Command-----> " & the_initial_command & " >" & return & theResult & return)
set the_compiler_command to "gcc_select 3.3"
set theResult to do shell script the_compiler_command
tell text view 1 of scroll view 1 of window 1
set contents to contents & return & "Command-----> " & the_compiler_command & " >" & return & theResult & return
end tell
works great (watch, I get attacked):
Command-----> ipfw list 2>&1 >
65535 allow ip from any to any
Command-----> gcc_select 3.3 >
You are already using gcc version 3.3 as the default compiler.
Alright, with some fiddling, your “call method” ?subourtine? worked just as I wanted. After each shell script, the output gets put into the window, so on the say 5th shell script the command&result of scripts 1-4 are visible. Thanks (yet again). All my installXXX functions call this, but this one is different to handle the errors about folders&stuff—but it does update:
to install2(the_admin_password)
--updating of apt-get information
--the weak link area!!!
-- I am unable (for whatever reason) to post the output of the apt-get command
--
set the_aptget_update_command to "source /sw/bin/init.sh; sudo apt-get update 2>&1"
try
set theResult to do shell script the_aptget_update_command password the_admin_password
--should be like "Hit http://us.dl.sourceforge.net 10.2-gcc3.3/current/main Release"
on error
set theResult to "Some non-critical errors were encountered"
end try
update_the_window_information(the_aptget_update_command, theResult)
to update_the_window_information(the_posted_command, the_posted_output)
set the_posted_command to "Command----->" & the_posted_command & " >" & return
set the_posted_output to the_posted_output & return & return & "•••••••••••••••••••••••••••••••••••••••••" & return & return
tell text view 1 of scroll view 1 of window 1
set contents to (contents & the_posted_command & the_posted_output)
set all_text to contents
set the_length to (length of all_text)
call method "scrollRangeToVisible:" of object it with parameter {the_length, the_length}
end tell
end update_the_window_information
Your"Installerish" program on your website as well as “Landmine” contribute the the last function. Now onto the main install loop… where I will probably use your repeat loop as a template (at this point YOU are more of the author of the program than I am ) A tribute to your prowess and my dimness.
Tried to post this a couple of times but it always ends up as a reply to a previous message… I’ll try again:
I have a simple Photoshop droplet on my desktop that, whenever I drag an image or a folder onto it, calls the relative action in PS (just converting in CMYK, 300 dpi, and save as Eps). The point is exactly this: I can’t tell PS thru Automation → Batch to save in the original folder.
I’ve downloaded the Photoshop Scripting plug in, I think that should help, but it means writing code, which I can’t… Well just a bit, it is.
Can I write a script that in batch from the Finder calls the correct PS Action and then sends the files again to the Finder for the saving procedure?
thx,
Guido