1

I used to run a shell command with AppleScript for authentication to a radius server, this was running fine as I could specify a parameter for the password.

the shell process was updated and don't accept the password parameter anymore and have to be done separately (prompted by terminal), so in terminal its look like it

~mycommand authenticate -username 
~password

unless I'm wrong "do shell script"m run in different instance so it's no point doing

do shell script + auth command
do shell script + password

is they anyway I can still use AppleScript and somehow let AppleScript answer with the password?

2
  • 1
    If there is no way to pass the password with the initial command, then you will need to script either Terminal or iTerm, the latter being more AppleScript scriptable. – user3439894 Jan 31 at 11:31
  • that make sense, thanks – Kevin Jan 31 at 11:34
1

The following example AppleScript code shows an example of how it could be coded for iTerm2.

set myPassword to text returned of ¬
    (display dialog "Enter Password:" default answer "" with hidden answer)

tell application "iTerm"
    set myWindow to (create window with default profile)
    tell myWindow to tell the current session
        write text "echo mycommand authenticate -username"
        delay 1
        write text "echo " & myPassword
        delay 1
    end tell
    close myWindow
end tell

Notes:

As coded, it uses echo just for testing purposes, obviously you'd remove echo and "echo " & for production run.

The delay commands may need to be adjusted, or may not be necessary at all. Test with the actual commands to see.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .