Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Apple Software > Mac Programming
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 4, 2009, 12:55 PM   #1
petersondw10
macrumors newbie
 
Join Date: Nov 2009
Location: Whitewater
Issue with Applescript

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
petersondw10 is offline   Reply With Quote
Old Nov 4, 2009, 01:20 PM   #2
chown33
macrumors 6502a
 
Join Date: Aug 2009
Code:
else
tell application "Installer" to activate
return
end tell
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.
chown33 is offline   Reply With Quote
Old Nov 5, 2009, 10:55 AM   #3
petersondw10
Thread Starter
macrumors newbie
 
Join Date: Nov 2009
Location: Whitewater
End of script error

Quote:
Originally Posted by chown33 View Post
Code:
else
tell application "Installer" to activate
return
end tell
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.
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.

Last edited by petersondw10 : Nov 5, 2009 at 11:09 AM.
petersondw10 is offline   Reply With Quote

Reply

Mac Forums > Apple Software > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 06:29 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2002-2010, MacRumors.com, LLC