Is it possible to convert an apple script w/ Idle to Shell Script?

The Apple Script repeats every minute when saved as an application and the box is checked as "stay open after run handler". I used this method to convert it to Shell Script: How do I convert this Applescript to Terminal osascript? , but it won't repeat as it does in the Apple Script. However it will work without the idle commands, but of course, it doesn't repeat. How do I get it to work? Is there a better syntax to use to have it repeat than #idle, #return 60 #end idle?

Apple Script

on idle
    tell application "Finder"
        if not (disk "Backup_Server" exists) then
            display alert "Backup_Server not found, please mount"
        end if
        delay 5
        if not (disk "Backup_Server" exists) then
            display alert "Backup_Server still not found, please submit a ticket"
            return 60
        end if
    end tell
end idle
on quit
    continue quit
end quit

Shell Script

#!/usr/bin/osascript
on idle
    tell application "Finder"
        if not (disk "Backup_Server" exists) then
            display alert "Backup_Server not found, please mount"
        end if
        delay 5
        if not (disk "Backup_Server" exists) then
            display alert "Backup_Server still not found, please submit a ticket"
            return 60
        end if
    end tell
end idle
on quit
    continue quit
end quit

Solution 1:

With an AppleScript script saved as a shell script you cannot use on idle, and return 60 unless you want return 60 to return 60

Use a repeat loop instead of an on idle handler, and replace return with delay.

The on quit handler is only good if you issued a quit command elsewhere in the code, otherwise you'd need to use ⌃C to quit the AppleScript shell script to break out of the repeat loop, unless you have coded a way out of it.