2

The following code is an example of what I'm using at the moment, but it keeps erroring out on me:

do shell script "find /Applications -name 'Bingo.app' > /tmp/remove_files" with administrator privileges
if exists "/tmp_malware_alternate" then
    do shell script ("for i in `cat /tmp/remove_files`; do rm -rf $i") with administrator privileges
    do shell script "rm -rf /tmp/remove_files" with administrator privileges
end if

It's supposed to find the existence of a file (in this case, Bingo.app) and write it to a temporary file (/tmp/remove_files), which it does, and then check to see if the temporary file was written. If it was, it will look into that temporary file, and delete each file (specified by i) in the temporary file listing, then remove the temporary file itself.

Instead, all it ever does is return an error:

/bin/sh: -c: line 1: syntax error: unexpected end of file

or

error "/bin/sh: -c: line 1: syntax error: unexpected end of file" number 2

What am I missing in this?

4

You need to close the for loop:

do shell script ("for i in \`cat /tmp/remove_files\`; do rm -rf $i") with administrator privileges

should be:

do shell script ("for i in \`cat /tmp/remove_files\`; do rm -rf $i; done") with administrator privileges
  • 1
    Oh, I didn't think of it that way. I will check this when I get home tonight. – Danijel-James W Nov 18 '13 at 3:42
  • These AppleScript commands are incorrect. They have antislashes, which are not present in the question of @Danijel. – Nicolas Barbulesco Nov 19 '13 at 12:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .