Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 16 votes, 5.00 average. Display Modes
Old 01-27-2012, 05:54 AM   #1
plafundum2
Prospect
 
Join Date: Jan 2012
Posts: 3
OSX Lion: Launchd VMware script stops unwanted

Hi all, I am new on the forum, but definitely not on OSX and Unix. Still i have an persistent issue.

I wrote a start script, in this case for VMware. Runs perfectly when hit from commandline: The script starts VMware, then the script exits and VMware keeps running.

Basically, this is the shell script, mark the backticks:
`/Applications/VMware\ Fusion.app/Contents/Library/vmware-vmx -x /Users/pietje/Virtual\ Machines/Ubuntu\ 64-bit.vmwarevm/Ubuntu\ 64-bit.vmx >> $logFile 2>&1 &`

The following script will make Launchd start VMWARE, and also keep it running, but now the bash script will remain running.
`/Applications/VMware\ Fusion.app/Contents/Library/vmware-vmx -x /Users/pietje/Virtual\ Machines/Ubuntu\ 64-bit.vmwarevm/Ubuntu\ 64-bit.vmx & >> $logFile 2>&1`

But when calling with launchdaemon, the script runs, starts VMware. When the bash script ends however, VMware gets terminated too.
Here is my plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.pietje.launch.vmware</string>
<key>ProgramArguments</key>
<array>
<string>/Users/pietje/bin/bash/com.pietje.launch.vmware.plist.sh</string>
<string>LaunchDeamon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>


I have tried all kinds of stuff. also nohup, but that will not work too, gives
nohup: can't detach from console: Inappropriate ioctl for device
Also <key>KeepAlive</key> <true/> does not work

Any guru here who can help me?
plafundum2 is offline   Reply With Quote
Old 01-27-2012, 10:51 AM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,459
Why are you using backticks in your script? Backticks are used to capture the output of a command - that doesn't seem relevant here.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 01-27-2012, 01:27 PM   #3
Hal Itosis
Hall of Famer
 
Join Date: Apr 2002
Posts: 3,315
This may be one of those cases where it's better to employ launchd directly, instead of having it call upon a script. E.g. this should work:

Code:
:
:
<key>ProgramArguments</key>
<array>
	<string>/Applications/VMware Fusion.app/Contents/Library/vmware-vmx</string>
	<string>-x</string>
	<string>/Users/pietje/Virtual Machines/Ubuntu 64-bit.vmwarevm/Ubuntu 64-bit.vmx</string>
</array>
:
:

NB: as can be seen in my (code fragment) version, we should not escape\ spaces or add any "quoting" in the plist... since those <string> fields get quoted when read by launchd.

NB2: since we aren't relying on any script process to act as our middleman, there's no need for that backgrounding (&) business.

Also, I left out the >> $logFile 2>&1 part... since we don't know the actual path there.
__________________

chown -R us /your\ base/

-HI-

.

Last edited by Hal Itosis; 01-27-2012 at 01:31 PM.
Hal Itosis is offline   Reply With Quote
Old 01-30-2012, 06:23 AM   #4
plafundum2
Prospect
 
Join Date: Jan 2012
Posts: 3
Without bakticks teh script does not run well.

@ Hal Itosis: your posting seems the best hint so far, got it also from a friend of mine. Thanks especially for the remarks (the two NB's) because I am sure those will save me two or more hours! :-)

I keep u posted on the results.
plafundum2 is offline   Reply With Quote
Reply

Tags
launchd bash vmware lion

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:54 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.