Archive for April, 2006

Quickcommand

Posted in Applescript, Calendar on April 19th, 2006

Ein Freund der erst vor kurzem zum Mac gewechselt ist hat mich letztens gefragt ob es unter OS X nicht sowas gibt wie “Alt-F2″ bei KDE.

Ich musste das verneinen, meinte aber dass man sich sowas mit Applescript und einem Hotkeytrigger (hier wirds Geschmackssache, ich nutze für sowas Quicksilver) selber basteln kann. Herausgekommen ist dabei folgendes Script:


set theResult to display dialog "Enter command" default answer "" buttons {"Execute", "Execute with Feedback"} default button 1
set theCmd to text returned of theResult
set Exec to theCmd
if button returned of theResult is "Execute" then
do shell script Exec
else
set t to do shell script Exec
display dialog t
end if

Natürlich ist das nur eine erste Idee, und lässt sich nach Belieben verändern, anpassen, erweitern, etc…

Info vom System Profiler

Posted in Applescript, Calendar on April 7th, 2006

Je umfangreicher und detaillierter die Infos die man im Supportfalle bekommen kann sind, umso eher kommt man einem Problem auf die Schliche. Um als Admin den User mit der Problemsuche möglichst wenig zu belasten, habe ich mir mal folgendes Script zusammengebastelt, das dem User eigentlich nur noch einen einzigen Mausklick abverlangt. Und selbst den könnte man evtl. sogar noch wegrationalisieren, aber beim Versenden von Daten ist es nicht nur eine Frage der Machbarkeit/Bequemlichkeit, sondern auch des Vertrauens wenn das Senden der User anstossen muss. Ausserdem bleibt ihm so die Möglichkeit evtl. weitere Infos in die Mail zu schreiben.


set theHost to do shell script "hostname"
set theUser to do shell script "whoami"
set theCmd to "system_profiler > /Users/" & theUser & "/Desktop/sysprof.txt"
do shell script theCmd
set theAttachment to "/Users/" & theUser & "/Desktop/sysprof.txt"
set theSubject to "System Profiler | " & theHost
set theContent to "Systemprofil im Anhang"
set theSenderAdress to "sysprof@" & theHost
set theRecipient to "Admin"
set theRecipientAdress to "admin@firma.de"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return}
tell newMessage
set visible to true
-- set sender to theSenderAdress
make new to recipient at end of to recipients with properties {name:theRecipient, address:theRecipientAdress}
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
activate
-- send newMessage
end tell
end tell

Das Script ruft System Profiler auf, und speichert die gesammelten Daten in die Datei “sysprof.txt”, und verschickt diese Datei dann per Mail an den Admin.
Veränderungen/Erweiterungen sind natürlich beinahe endlos möglich.

Den Artikel Info vom System Profiler