Passing a variable from osascript to bash
Passing a variable from osascript to bash
- Subject: Passing a variable from osascript to bash
- From: "LaMantia, Brian" <email@hidden>
- Date: Sat, 09 Feb 2019 16:20:57 +0000
- Disclaimersource: eop
- Thread-topic: Passing a variable from osascript to bash
Question for all. I have a workflow I want to get rolling but need to know if
I’m approaching the right way. I want a UI that will prompt a user for a code
which needs to be passed to terminal as a variable. Once the command runs I
want the results passed back to a UI so they know if it passed or failed.
1. User given token
2. User executes script
3. Token entered in UI / User clicks ok
4. Token passed to cli
5. Command runs
6. results echoed back to user
7. Ok to dismiss message
8. Done
I have little experience with osascript but was given the bash script to test
with. Not sure if I want a bash script that executes osascript or the opposite.
Which is the cleanest idea?
I’m I on the right path? Assistance is very appreciated.
-Brian
#!/bin/sh
##Get Current User
currentUser=$( /usr/bin/stat -f %Su /dev/console )
echo "Current user is $currentUser"
/usr/bin/osascript <<EOT
set theResponse to display dialog "What's your code?" default answer "" with
icon stop buttons {"Cancel", "Continue"} default button "Continue" with hidden
answer
display dialog "My Secret Code is " & (text returned of theResponse) & "."
EOT
The information contained in this message is proprietary and/or confidential.
If you are not the intended recipient, please: (i) delete the message and all
copies; (ii) do not disclose, distribute or use the message in any manner; and
(iii) notify the sender immediately. In addition, please be aware that any
message addressed to our domain is subject to archiving and review by persons
other than the intended recipient. Thank you.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden