Skip to main content
Question

osascript wait for input before starting next line

  • June 25, 2019
  • 1 reply
  • 1 view

ImAMacGuy
Forum|alt.badge.img+23

I have an osascript I want to wait for input before proceeding to next line, I THINK I need to do a set T in it but It keeps failing...

#!/bin/bash

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u $loggedInUser)

if [[ "$loggedInUser" != "root" ]] && [[ "$loggedInUser" != "_mbsetup" ]]; then
    ## Create local script
    cat << EOD > /private/tmp/computerrenamescript.sh
#!/bin/bash

TT=$(/usr/bin/osascript -e 'tell application "System Events" set T to set MacTYPE to text returned of (display dialog "Please input the machine type - " default answer "" with icon 2)')

BB=$(/usr/bin/osascript -e 'tell application "System Events" to set BRAND to text returned of (display dialog "Please input the brand - "" with icon 2)')
.
.
.

Any help is appreciated!

1 reply

ehemmete
Forum|alt.badge.img+5
  • Contributor
  • 13 replies
  • June 25, 2019

Try your osascript lines like this:

TT=$(/usr/bin/osascript -e 'set MacTYPE to text returned of (display dialog "Please input the machine type - " default answer "" with icon 2)')

BB=$(/usr/bin/osascript -e 'set BRAND to text returned of (display dialog "Please input the brand - " default answer "" with icon 2)')

You shouldn't need 'tell application "System Events"' and you were missing the 'default answer ""' part of BB, but ended up with an extra '"'. I assume the '$' has something to do with this being written out to a file, so I left those.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings