Advice on implementing a long shell script
Posted: Fri Nov 02, 2012 6:18 pm
I am writing an app to partition a hard drive into multiple parts. I will use a shell command to do this, but the command can take some time to complete. Also, I would like the user to be able to see the output from the command in case there is a problem. What is the best approach to this?
I was planning on running the shell command in the background and redirecting all output to a file, then creating a new sub-stack that would poll the file and display it to the user until the command is complete. The substack would have one card with one field. The card's script is below.
This approach may be completely wrong, but if it is not, the problem I am having is that I can't figure out how to break out of the repeat. I thought sending that message would signal the repeat to stop, but apparently not.
Any advice on how to proceed would be appreciated.
I was planning on running the shell command in the background and redirecting all output to a file, then creating a new sub-stack that would poll the file and display it to the user until the command is complete. The substack would have one card with one field. The card's script is below.
Code: Select all
on openstack
put empty into field "field"
repeat until the endRepeat with messages
put url "binfile:/Users/cpatton/Desktop/baz.log" into field "field"
put shell("ps -axo comm | awk '/[a]sr/{print}'") into isitrunning
if isitrunning contains "asr" then
else
send "endRepeat" to this card
end if
wait 0 milliseconds with messages
end repeat
end openstack
on endRepeat
put "ASR complete." after field "field"
end endRepeat
Any advice on how to proceed would be appreciated.