Process status

HI,

not sure if this is possible but if someone knows of a way I’m open to any suggestion :slight_smile:

I’ve been working on a script that at some part, does an rsync from a choosen folder to a new destination. Is there a way to have some sort of process bar that can show us the rsync status?

I’ve been reading here asnd there and it seems that this is not that straighforward. If it can make things easier, i don’t really need a 100% accurate status (It seems that process bar updating is not quite easy) but just a roughly estimate of where the process at and so we can make sure that it is indeed running and din’t crash.

thanks a lot
Frederico

Hi,

you can see the progress status in Terminal.app using the -status switch of rsync,
but it’s not possible with do shell script, because it requires a second asynchronous thread

thanks for the reply Stefan. Unfortunately, I’m working with shell script as I have to find all .mhl files once the copy’s done. Right now, the command look like this

do shell script "/usr/bin/rsync -vautE " & quoted form of text 1 thru -2 of sourceFolder & space & quoted form of targetFolder
	set theFiles to paragraphs of (do shell script "/usr/bin/find " & quoted form of (targetFolder & sourceFolderName) & " -type f -name '*.mhl'")

I’ve been trying to use the do script instead of the do shell script, but doing so I then got an error on the set Files to paragraphs saying "error “error “Terminal got an error: Can’t get every paragraph of tab 1 of window id 20302.” number -1728 from every paragraph of tab 1 of window id 20302”

Is there a way to change my shell script command to a do command so I can use the -status? And if so, is there no other ways that I can get a status (even if it means using a third party outside of Applescript)?

Thanks again
Frederico

the dilemma is

¢ with do script in Terminal.app it’s not possible to get any output from stdout into AppleScript
¢ with do shell script in AppleScript it’s not possible to get continuous output from stdout

A possible solution is an application written in AppleScriptObjC or even Objective-C

Thanks a lot Stefan,

I’m might learn to survive without the progress bar then :wink:

One other thing. at the end of my script, I’m sending email notifications with variables (recipient name, attachment, content, etc…) that was set at the very beginning of my script. Everything worked perfectly but I would like to ad the feature of getting the email content fro predefined text files. I was able to do so by creating rtf files in text edit and convert them to HTML in applescript with this script

et rtfFile to choose file with prompt "Choose the RTF file to email as HTML:" without invisibles
set theHTML to do shell script "/usr/bin/textutil " & " -stdout -format rtf -convert html " & quoted form of POSIX path of rtfFile & " | /usr/bin/tidy -b -utf8"

tell application "Mail"
	set newMessage to make new outgoing message at end of outgoing messages with properties {visible:false}
	tell newMessage
		make new to recipient at end of to recipients with properties {address:"frederico.cengarle@visionglobale.com"}
		set subject to "yeah"
		set html content to theHTML
		send
	end tell
end tell

and it seems to work just fine. The only issue is when I’m trying to add the attached file

make new attachment with properties {file name:theAttachment} at after the last paragraph

I’ve got an error saying ‘‘error “Mail got an error: Can’t make last paragraph of html content of outgoing message id 42 into type specifier.” number -1700 from last paragraph of html content of outgoing message id 42 to specifier’’

Is it possible to add an attachment to an email that has html content? And if not, is there another way to get the email content from a text file (doesn’t need to be an rtf if it could help)

thanks

I doubt that you could attach a file to a html body, try it with plain text
For testing purpose I removed the send command and set visible to true


set rtfFile to choose file with prompt "Choose the RTF file to email as Plain Text:" without invisibles
set plainText to do shell script "/usr/bin/textutil " & " -stdout -format rtf -convert txt " & quoted form of POSIX path of rtfFile

tell application "Mail"
	set newMessage to make new outgoing message at end of outgoing messages with properties {visible:true}
	tell newMessage
		make new to recipient at end of to recipients with properties {address:"frederico.cengarle@visionglobale.com"}
		set subject to "yeah"
		set content to plainText
		tell content
			make new attachment with properties {file name:theAttachment} at after the last paragraph
		end tell
	end tell
end tell

Thanks Stefan :slight_smile: