How to create script that run sudo-command, via automator?

Hi

I'd want to create script to automate one command I need quite often. I just can't get this to work.
I'm not using english OS, but I think this is what I do. In automator I choose Utilities -> Run script

Here's the script I try to run:
sudo "/Library/Application Support/VMware Fusion/boot.sh --restart"

I found some tip to do it like this:
do shell script "sudo /Library/Application Support/VMware Fusion/boot.sh --restart password "pass" with administrator privileges
Where pass is my admin password.

This does not work, either.
Could anybody help me on this?

Thanks...

____________
Tomi Toivonen

Message was edited by: Tomi

Mac OS X (10.5.1), 17" MBP

Posted on Jan 16, 2008 12:34 PM

Reply
8 replies

Jan 17, 2008 12:40 AM in response to _Tomi_

This is not working. What's wrong?


What's wrong is that the '--restart' is a parameter for boot.sh, and therefore needs to be included within the quotes.

Additionally, the shell uses spaces to divide parameters, so the spaces in the command will make it appear as multiple commands - '/Library/Application', 'Support/VMware' and 'Fusion/boot.sh'. You need to escape them using a backslash:

<pre class=command>do shell script "/Library/Application\ Support/VMware\ Fusion/boot.sh --restart" password "pass" with administrator privileges</pre>

If it's outside of the quotes it would be interpreted as a parameter to 'do shell script' and it won't know what to do with that.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to create script that run sudo-command, via automator?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.