Scripting a command to unix with sudo fun
Scripting a command to unix with sudo fun
- Subject: Scripting a command to unix with sudo fun
- From: garrett <email@hidden>
- Date: Thu, 14 Mar 2002 21:01:26 -0600
The goal:
i have an app that i must sudo in order for it to work correctly.2 ways to
approach this, 1 using the terminal app, the other directly from AS using
do shell script.
I like example 1 because a physical gui item open for me to close when i'm
finished, albeit clunky. the second example is nice because its seamless
with no clutter. however, once i initiate the process, i don't know how to
kill it.
go easy on me guys - scripting newbie.
(please read everything before commenting):
Example 1:
i can script the terminal to sudo the app, enter a password, leave that
terminal window open... when i'm thru with the app, close the terminal
window, thus shutting down the process.
the code:
tell application "Terminal"
activate
do script with command "sudo
/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp
/Applications/Utils-Network/RumpusServer/Rumpus2.1Carbon "
end tell
ok. term window opens, issues the sudo, then the password prompt comes
back, and i have to manually enter my password. now aside from the safety
concerns of doing this, how can i add the password to this command to have
it do everything automatically? I have tried doing multiple commands on
one line by adding the "; " and it doesn't work. any ideas?
it puts the password on the same line as the sudo command in the terminal
window:
sudo
/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp
/Applications/Utils-Network/RumpusServer/Rumpus2.1Carbon; mypassword
[24-148-81-128:~] garrettn% sudo
/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp
/Applications/Utils-Network/RumpusServer/Rumpus2.1Carbon; mypassword
EXAMPLE 2:
directly from AS using the command do shell script. Since I'm real
unfamiliar with unix, am i running 2 processes here, the LaunchCFMApp
process and then Rumpus.? so if i were to manually quit Rumpus from the
program, does it leave the LaunchCFMApp running? i know if i use example
one, by closing the terminal window, i'm killing the whole process.
do shell script "sudo
/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp
/Applications/Utils-Network/RumpusServer/Rumpus2.1Carbon ; mypassword"
Ok. This works. However, how can i script the system to tell me just what
process it created, so i can later use that PID to kill it? for example
the LaunchCFMApp is running many times on a typical system, so how do i
identify the one i just launched... is there some feedback that i can get
back from the do shell script command that will give me the info i need?
or is it ok to just kill the app Rumpus and leave that LaunchCFMApp
process going?
------
garrett
email@hidden
Titanium G4/400
512MB Ram
OS X 10.1.3 (9.2.2 Classic)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.