Shell Script Help-- Having the output going somewhere

Hi guys, I have an app that starts a server from a do shell script command.
It technically never ends, and it it constantly outputting data. As a result when I run the program, the server starts and runs fine, but the program locks up because it is waiting for the command to end. Is there a way I can get the data to go somewhere, I don’t need to look at it so it could just disappear. Thanks a ton!

Max


on clicked theObject
	if theObject is button "Start" of window "Window" then
		set serverName to content of text field "servername" of window "Window"
		set adminPass to content of text field "adminpass" of window "Window"
		set serverPassword to content of text field "serverpassword" of window "Window"
		set botsTrue to state of button "bots" of window "Window"
		set statsTrue to state of button "stats" of window "Window"
		set serverPass to state of button "serverpass" of window "Window"
		set shellScript to "/Applications/Zap\\!\\ Folder/ZAP.app/Contents/MacOS/ZAP -dedicated -hostname " & serverName
		set shellScript to shellScript & " -adminpassword "
		set shellScript to shellScript & adminPass
		if botsTrue = 1 then set shellScript to shellScript & " -bots"
		if statsTrue = 1 then set shellScript to shellScript & " -stats"
		if serverPass = 1 then set shellScript to shellScript & " -password "
		if serverPass = 1 then set shellScript to shellScript & serverPassword
		do shell script shellScript
		display dialog shellScript
		
	end if
	
end clicked

Have you tried to just add another ampersand to the shell script? I.e. the end of your handler might look like:


        if serverPass = 1 then set shellScript to shellScript & serverPassword
        set shellScript to shellScript & " &"
        do shell script shellScript
        display dialog shellScript
    end if 
end clicked

This will run the server as a background job - which might do the trick for you since the script command will return right after execution, while the server keeps running in background.

Regards,
Daniel

Model: iBook g3/800 14"
Browser: Safari 312.3.3
Operating System: Mac OS X (10.3.9)

Hmm, nope didn’t seem to do the trick, thanks though, any other ideas?

It seems that AppleScript gets stuck on a do shell script as long as an output can arrive. To avoid it, you should redirect the output of your daemon to /dev/null, with e.g. an additional line before you call the script, like this one :

set shellScript to (shellScript & " &> /dev/null")

Thanks for the reply!
It still doesn’t seem to work. Now when I try to start the server it won’t start.
Any suggestions?

Would it help at all if I were to send the xcode project?

Anyone think of anything else?

I don’t know if this is the problem, but there is an ampersand missing from the end, try this:

set shellScript to (shellScript & " &> /dev/null &")

Yey! That worked thanks sooooo much!