scripting

Discussion in 'Mac Programming' started by Tech198, Jul 3, 2017.

  1. Tech198 macrumors G4

    Joined:
    Mar 21, 2011
    Location:
    Australia, Perth
    #1
    I have Mac Mini that I control remotely at all times as its main use is a media server with no keyboard and mouse attached..

    The problem comes specially after applying security updates which need restarting, u must login with attached keyboard & mouse (locally).. I found out that even
    Code:
    fdesetup authrestart
    using sudo will also work not just with FileVault but also with security updates (although Apple's site only mentions specially remote access Filevault on restart) I found that bit on OS X daily.

    The problem is i must run it from Terminal... I have doe a quick bash scrip to try an automate the process, but i still must have Terminal open by userin order to execute..

    Is is possible to maybe active this all automatically by a call from Applescript? I know password must be entered manually, which i don't have a problem with.... I just need the script to automatically launch Terminal first. and do script...
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi,

    Maybe you should look at "do shell script"? For example...

    Code:
    set theResult to do shell script "date"
    
    Have a look in StandardAdditions.osax's scripting dictionary, and there are options for supplying username/password and running commands with admin privileges.

    Hope that helps
     
  3. Tech198 thread starter macrumors G4

    Joined:
    Mar 21, 2011
    Location:
    Australia, Perth
    #3
    Thanks... However do shell script requires me to still have "bash script"" since "fdesetup" is used at Terminal prompt.... Is there a way do just do this vi APpleScript only?

    I prefer to type in password myself for security reasons, but automated (i'll have a look at that). yet i do not wish to have two files .sh and Apple script just do accomplish this ether if possible.... just one or the other. I prefer using Apple script if i can but not sure if u can do bash directly in Applescript or weather u must call .sh which i really do not wish to do. As this requires having both files.

    I can leave out the "date" because its not set to automatically restart at any given date... I just execute the script before a security update is applied so on next boot i can login remotely. The whole idea is for doing this... since i do not have Keyboard and mouse attached to Mac mini,, therefore having the script ready to run on the remote system is a good idea..
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #4
    Hi,

    I think you misunderstand how "do shell script" works (or possibly I misunderstand your requirements!). If I understand you correctly, you just want to issue a bash command. If so, there is no need for an additional bash script, and the AppleScript can deal with the username/password stuff. Take a look here for more info:

    https://developer.apple.com/library/content/technotes/tn2065/_index.html
     

Share This Page