Issue with Applescript

Discussion in 'Mac Programming' started by petersondw10, Nov 4, 2009.

  1. macrumors newbie

    Joined:
    Nov 4, 2009
    Location:
    Whitewater
    #1
    This is a script I'm writing to be used in a program that auto configures OSX wireless settings. I'm getting a few errors and I'm not sure why I'm getting those errors. The Syntax error is Expected “end” but found “end tell” in the bolded section.

    -- Prompt for Network username and password. Write username to a file and return the password to the main script
    -- This script expects to receive the Mac Admin password, Logs locations and MBAirPresent variable from the parent script as arguments
    -- Ex. osascript /path/to/this/script $MACPASS $LOG $ERRORLOG $MBAirPresent

    on run argv
    set myMacPass to item 1 of argv
    set LOGS to item 2 of argv
    set ERRORLOG to item 3 of argv
    set MBAirPresent to item 4 of argv
    set theUser to (do shell script "echo $USER")
    set myPass to ""
    set counter to 1

    tell application "Finder"
    with timeout of 10000 seconds
    activate
    repeat until myPass is not ""
    if counter &1 > " & ERRORLOG" then
    do shell script "echo \"exit 99 User cancelled installation.\" 2>&1 >> " & LOGS
    else
    tell application "Installer" to activate
    return
    end tell
    end if
    if button returned of acctBox is "OK" then
    if myAcct is not "" then

    -- Remove any trailing @mydomain.com information from network name
    if myAcct contains "@" then
    set myAcct to text 1 through ((offset of "@" in myAcct) - 1) of myAcct
    end if

    -- Test to see if Network password is correct
    set myPassBox to display dialog "Please enter your UW-Whitewater password:" & return & return & "Be careful to enter it correctly!" & return & "This password is case-sensitive!" default answer "" buttons {"Quit", "OK"} default button 2 with title "UW-Whitewater Wireless Setup" with hidden answer
    if button returned of myPassBox is "Quit" then
    tell me
    do shell script "echo \"exit 99 User cancelled installation.\" 2>&1 > " & ERRORLOG
    do shell script "echo \"exit 99 User cancelled installation.\" 2>&1 >> " & LOGS
    end tell
    tell application "Installer" to activate
    return
    end if
    set myPass to the text returned of myPassBox

    -- test to see if network password is blank
    if myPass is not "" then

    -- Write username to file for parent script to pickup
    if myAcct is not "" then
    tell me
    do shell script "touch /private/tmp/cu_wireless/WirelessUserNameIs" & myAcct user name theUser password myMacPass with administrator privileges
    end tell
    end if
    if myAcct is "" then
    tell me
    do shell script "echo \"exit 21 Wireless username is blank. Unknown error.\" 2>&1 > " & ERRORLOG
    do shell script "echo \"exit 21 Wireless username is blank. Unknown error.\" 2>&1 >> " & LOGS
    end tell
    tell application "Finder"
    activate
    display dialog "Wireless username is blank. Unknown error." & return & return & "Please try running the Wireless Installer again." buttons {"OK"} default button 1 with icon caution
    end tell
    tell application "Installer"
    activate
    end tell
    return
    end if
    tell application "Installer"
    activate
    end tell

    -- Send wireless password to parent script
    return myPass

    end run
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    Code:
    else
    tell application "Installer" to activate
    return
    [B]end tell[/B]
    end if
    
    Assuming the else to end if is all supposed to be one block, the end tell is wrong. The form "tell x to y" is a one-line form that doesn't take an end tell.
     
  3. thread starter macrumors newbie

    Joined:
    Nov 4, 2009
    Location:
    Whitewater
    #3
    End of script error

    Thanks, fixed that and realized that I had a few if statements that weren't ended. It compiles but now I cant get it to save in script editor.
     

Share This Page