I need help getting my panel to work. I want it to come out of the main panel like the panel does in the “Display Panel” example but mine won’t open, can you help?
here’s the code:
do shell script "ps -aux | grep ssh | grep -v sshd | grep -v grep | wc |awk '{print $1}'"
if result ? "1" then
do shell script "ps -aux |grep ssh |grep" & UsrID & "@ | wc |awk '{print $1}'"
if result ? "1" then
-- havn't finished this part yet
exit repeat
else
if not (exists panelWIndow) then
load nib "loginpane"
set panelWIndow to window "login"
display panelWIndow attached to window "launcher"
end if
end if
else
load nib "loginpane"
set panelWIndow to window "login"
display panelWIndow attached to window "launcher"
end if
The reason that your panel didn’t load or show the way you wanted it to, was because you had no code to load the opject. In AppleScript Studio, every applescript line needs to be nested in a command.
here is a little program that I wrote to help you along.
-- SSH Interface.applescript
-- SSH Interface
-- Created by Daniel McCoy on Mon Nov 01 2004.
-- Copyright (c) 2004 Daniel McCoy II. All rights reserved.
property UsrID : "username"
property Server : "serve" -- applescript limits the name to 5 characters
property FullServerName : "server.domain.com"
on will finish launching
do shell script "ps -aux |grep ssh |grep -v sshd | grep -v grep | grep " & Server & " | wc |awk '{print $1}'"
if result >= "1" then
set the contents of text field "MainStatus" of window "MainWindow" to "SSH Connection to " & FullServerName & " Active"
else
set the contents of text field "MainStatus" of window "MainWindow" to "SSH Connection Not Active"
display panel window "LoginWindow" attached to window "MainWindow"
set the contents of text field "LoginStatus" of window "LoginWindow" to "You have no active connections to " & Server
set the contents of text field "LoginStatus2" of window "LoginWindow" to "Please Enter Your Password"
set the contents of text field "Username" of window "LoginWindow" to UsrID
end if
end will finish launching
on clicked theObject
if name of theObject is "GoLogin" then
display panel window "LoginWindow" attached to window "MainWindow"
set the contents of text field "LoginStatus" of window "LoginWindow" to "You have no active connections to " & Server
set the contents of text field "LoginStatus2" of window "LoginWindow" to "Please Enter Your Password"
set the contents of text field "Username" of window "LoginWindow" to UsrID
else if name of theObject is "closeWindow" then
close panel window "LoginWindow"
else if name of theObject is "Login" then
set thePassword to the contents of text field "Password" of window "LoginWindow"
set theUser to the contents of text field "Username" of window "LoginWindow"
close panel window "LoginWindow"
tell application "Terminal"
activate
repeat with theWindow in window 1
do script "ssh -l " & theUser & " " & FullServerName in theWindow
delay 5
do script thePassword in theWindow
log "password sent"
end repeat
end tell
quit
end if
end clicked
I don’t understand what you mean, as far as loading the panel I had both
load nib "loginpanel"
and
set panelWindow to window "login"
display panelWindow attached to window "launcher"
but just to see if this would work changed my code to :
on will finish launching
do shell script "ps -aux | grep ssh | grep -v sshd | grep -v grep | wc |awk '{print $1}'"
if result ? "1" then
do shell script "ps -aux |grep ssh |grep" & UsrID & "@ | wc |awk '{print $1}'"
if result is not "1" then
display panel "login" attached to window "launcher"
end if
else
display panel "login" attached to window "launcher"
end if
end will finish launching
and it’s still not loading
while I was waiting for a response I worked on the other aspects of my code and now I’m getting button errors so if you could just look over my code and tell me precisely what it is I need to change and why I would be very appreciative.
on will finish launching
do shell script "ps -aux | grep ssh | grep -v sshd | grep -v grep | wc |awk '{print $1}'"
if result ? "1" then
do shell script "ps -aux |grep ssh |grep" & UsrID & "@ | wc |awk '{print $1}'"
if result is not "1" then
display panel "login" attached to window "launcher"
end if
else
display panel "login" attached to window "launcher"
end if
end will finish launching
on clicked theObject
if name of theObject is "quit" then
close panel "login"
close window "launcher"
else if name of theObject is "go" then
tell application "Terminal"
set theWindow to window 1
end tell
if contents of text field "ENGRAppInput" is "" then
set RunApp to contents of popup button "AvailApps"
if RunApp is "Pro-E" then
tell application "Terminal"
do script "proe" in theWindow
end tell
else if RunApp is "Matlab" then
tell application "Terminal"
do script "matlab" in theWindow
end tell
else if RunApp is "Arcview" then
tell application "Terminal"
do script "arcview" in theWindow
end tell
else if RunApp is "Hspice" then
tell application "Terminal"
do script "gsi" in theWindow
end tell
else if RunApp is "AcroRead" then
tell application "Terminal"
do script "acroread" in theWindow
end tell
else if RunApp is "Maple" then
tell application "Terminal"
do script "xmaple" in theWindow
end tell
else if RunApp is "Mathematica" then
tell application "Terminal"
do script "mathematica" in theWindow
end tell
end if
else
set RunApp to contents of text field "ENGRAppInput" of window "login"
tell application "Terminal"
do script "acroread" in theWindow
end tell
end if
else if name of theObject is "panelOK" then
set theWait to 3
set UsrID to contents of text field "ENGRUser" of window "login"
set UsrPasswd to contents of text field "ENGRPasswd" of window "login"
tell application "X11"
activate
end tell
tell application "Terminal"
activate
set theWindow to window 1
do script "ssh " & USERNAME & "@" & SERVER in theWindow
delay theWait
do script UsrPasswd in theWindow
delay theWait
do script "vt100" in theWindow
end tell
repeat
do shell script "ps -aux |grep ssh |grep " & theServer & "| wc |awk '{print $1}'"
if result ? "1" then
display dialog "connection to " & theServer & " is active"
exit repeat
end if
end repeat
close window "login"
end if
end clicked
on should quit after last window closed theObject
return true
end should quit after last window closed
thank you for all of your help, I know it can be frustrating working with a novice, but I am thank full for how patient you have been so far.
I looked over your code, it is looks fine to me. The problems you may be running into is how you have your object variables referenced in the Interface Builder application.
if you are running into problems like buttons not working once you click on them, they might not be named and or attached to your program.applescript file. You can check this by selecting a button, text field, etc and make sure the object info pallet it open. (Tools → Show Info)… Once that is open, check to make sure all your applescript names, usages, and connections to scripts are all correct. Loot at the applescript window (command 7) and make sure that if you are working with a button that the “action → clicked” has a check mark by it. and also make sure that it is connected with your program.applescript at the bottom of that same window. Make sure all our objects in your interface have an applescript reference name (the reference name is different from the title) and they are all connected to the applescript that they need to be using.
also make sure that the scripts that you are calling, like matlab, proe, etc have a valid path. like /Applications/matlab, or :Applications:matlab, depending on how you reference your file structure.