Running a bash script from within Applescript -


i'm having issue getting bash script execute within applescript. need applescript file prompt username , password bash script runs sudo permissions, doing tasks cannot done administrator, such writing /etc/.

as script (packaged inside .dmg file using platypus) distributed number of users, can't rely on absolute paths, , instead need path of applescript file when runs, sudo permissions, , run bash script within same directory.

so far, have been able come with, via posts , other sites, has resulted in osascript complaining can't find bash script. ideas?

it seems might work, syntax errors:

set wd shell script "pwd"  tell application "terminal"     set run_cmd "/bin/bash " & wd & "/osx.sh"     script run_cmd administrator privileges end tell 

if script saved application, must include :

set mypath path me 

the variable mypath complete path app. there, have add sub folder, "contents:resources:my_shell_script" know shell script is. don't forget convert path posix (unix) path shell script command.

to ask user password, can use display dialog hidden option not display typed characters :

set myinput display dialog "enter password" default answer "" hidden answer set mypwd text returned of myinput 

to user name, there many possible methods; 1 :

set username shell script "/usr/bin/whoami" 

however, if user has not admin privilèges, still have ask admin user name.

last, not least, shell script can run using shell script (as vadian says)

set r shell script "my_script-here" 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -