Fileserver per Apple Script steuern

H

Hoheit

Aktives Mitglied
Thread Starter
Dabei seit
23.04.2007
Beiträge
117
Reaktionspunkte
2
so, nach einiger Zeit und viel Gelese (Danke für die Tips überall, Suchen hilft!)
bin ich soweit:
Mein Script überprüft ob die Server HD's gemountet sind, und gibt ein Dialog aus, welcher mit erlaubt, die Platten zu mounten oder den Server herunterzufahren, andernfalls eben einen Dialog um den Server hochzufahren.

nun muss ich doch selber fragen, weil ich nicht wirklich weiter komm....
Code:
...--WOL
if button returned is "on" then
		do shell script "wakeonlan 00:30:84:77:f6:78"
		exit repeat
	end if
else --platten da!
	display dialog "Letz..." buttons {"mount", "off", "C"} default button 1 with icon 2 giving up after 3
	if button returned is "mount" then
		mount volume "smb://...
der Fehler ist "button returned kann nicht in Typ reference umgewandelt werden." da ich nOOb bin, verstehe ich diese Meldung nich und komm partout nich dahinter...bei WOL funktionierts doch auch!?!
Danke für die Hilfe
 
Zuletzt bearbeitet:
Hi,

ich bin zwar kein Applescript Profi aber ich würde sagen du solltest das "end if" erst nach dem "else" Statement einfügen. Ich vermute mal der Interpreter kommt durch den Syntax Fehler aus dem Tritt und bringt dadurch diese wenig hilfreiche Fehlermeldung.

Also
if .. else ... end if
statt
if ... end if else ...
 
Noi, Problem gelöst mit
Code:
if button returned of result is "mount" then
		mount volume "smb
 
soo, ich bin soweit fertig, jetz fehlt mir nurnoch ein Script, was mir die iTunes Bilbliothek auswählt, da der zu verwaltende Ordner automatisch umgestellt wird, sobald die Serverplatten gemountet sind.
Das Script macht folgendes:
- es startet via ssh & magicpacket meinen Server
- es wartet 55 sekunden
- mountet meine beiden Platten
- unmountet die Platten und schaltet meinen Server aus
- gibt via Growl nachrichten aus

die Gimmicks sind die Growlunterstützung & die variablen Dialoge
freue mich über Kritik und Anregungen!
Code:
--Growl überprüfen, registrieren & Messages schreiben

tell application "System Events"
	set isRunning to ¬
		(count of (every process whose name is "GrowlHelperApp")) > 0
	if isRunning is true then
		tell application "GrowlHelperApp"
			set the allNotificationsList to ¬
				{"dotheServer"}
			set the enabledNotificationsList to ¬
				{"dotheServer"}
			register as application ¬
				"dotheServer" all notifications allNotificationsList ¬
				default notifications enabledNotificationsList ¬
				icon of application "Script Editor"
		end tell
	end if
end tell

--checken ob Platten gemounted -> Server on? bzw. HD's ausgeworfen
set f to do shell script "ping -c 1 192.168.0.222;echo -n"
if f contains "100% packet loss" then
	display dialog "server_Off" buttons "on" default button 1 with icon 1 giving up after 3
	set d to result
	if button returned of result is "on" then
		do shell script "wakeonlan 00:30:84:77:f6:78"
		--40 sec Pause
		delay 55
		tell application "GrowlHelperApp"
			notify with name ¬
				"dotheServer" title ¬
				"Server Off" description ¬
				"bootin' Up" application name "dotheServer"
		end tell
		tell application "Finder"
			try
				mount volume "smb://user:password@ipdesservers/mountpoint"
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Server Mounted" description ¬
						"HD ist online" application name "dotheServer"
				end tell
				mount volume "smb://user:password@ipdesservers/mountpoint2"
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Server Mounted" description ¬
						"HD ist online" application name "dotheServer"
				end tell
			on error number -55
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Idiot!" description ¬
						"Server already mounted" application name "dotheServerdotheServer"
				end tell
				beep 2
				
			end try
		end tell
	end if
	
else
	display dialog "Letz..." buttons {"mount", "off", "C"} default button 1 with icon 2 giving up after 3
	set d to result
	if button returned of result is "mount" then
		tell application "Finder"
			try
				mount volume "smb://user:password@ipdesservers/mountpoint"
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Server Mounted" description ¬
						"HD ist online" application name "dotheServer"
				end tell
				mount volume "smb://user:password@ipdesservers/mountpoint2"
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Server Mounted" description ¬
						"HD ist online" application name "dotheServer"
				end tell
			on error number -55
				tell application "GrowlHelperApp"
					notify with name ¬
						"dotheServer" title ¬
						"Idiot!" description ¬
						"Server already mounted" application name "dotheServer"
				end tell
				beep 2
				
			end try
		end tell
	else if button returned of result is "off" then
		do shell script "~/welldone.sh"
		tell application "Finder"
			try
				eject disk "mountpoint"
				eject disk "mountpoint2"
			end try
		end tell
		tell application "GrowlHelperApp"
			notify with name ¬
				"dotheServer" title ¬
				"fil," description ¬
				"i've done well!" application name "dotheServer"
		end tell
	end if
end if
das Shell Script sieht so aus:
Code:
#!/bin/sh
ssh ipdesServers <<EOT
sudo shutdown -h now
password
EOT
 
so, Dummerweise hab ich nen buck entdeckt; Linux wird langsamer, auch wenn's nicht wirklich benutzt wird, dh. delay 55 ist zu wenig geworden, weiss jemand, wie man dies Prob. elegant lösen kann?
Danke!
 
hol dir halt den text aus dem fenster und mach eine schleife die solange wartet bis das richtige erscheint...
 
Zurück
Oben Unten