Ignore applescript errors from terminal

Discussion in 'Mac Programming' started by Laser47, Oct 28, 2005.

  1. macrumors 6502a

    Laser47

    Joined:
    Jan 8, 2004
    Location:
    Maryland
    #1
    Im pretty new to applescript and ive been trying to write a script that deletes a folder using terminal using administrative privlages. The thing im writing this script for another computer so i dont have the folder on it that i want it to delete. Is there a way i can tell applescript if it gets an error to ignore it and continue.
    Here is the script, bear in mind im new to applescript
    tell application "Terminal"
    activate
    do shell script "sudo rm -rf 'System Folder'" password pass with administrator privileges

    do shell script "echo " & "$ sudo bless -folder ~/System/Library/CoreServices" password pass with administrator privileges
    do shell script "echo " & "$ rm ~/Library/Preferences/ByHost/com.apple.Classic.some_number.plist" password pass with administrator privileges

    do shell script "$ rm ~/Library/Preferences/com.apple.Classic.plist" password pass with administrator privileges

    do shell script "$ rm ~/Library/Classic/.LoadClassicPref" password pass with administrator privileges

    do shell script "$ rm ~/Library/Classic" password pass with administrator privileges

    do shell script "$ sudo bless -folder /System/Library/CoreServices" password pass with administrator privileges



    By the way it is a script to remove classic
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Wrap the problem statements in try - on error -end try blocks:
    Code:
    try
    do some bad thing
    on error
    display dialog "error"
    end try
    
     
  3. thread starter macrumors 6502a

    Laser47

    Joined:
    Jan 8, 2004
    Location:
    Maryland
    #3
    thanks, it worked. Im almost dont the script, just need to install classic and see if it works.
     

Share This Page