Wim, thanks for your reply and sorry that it took me so long to reply again.

Wim Vander Schelden wrote:
> Are you sure your command returns? Maybe it blocks until the process
> ends? Is there any information you could give on the command you are
> trying to execute?

This is what I want to do:

port = 24800
synergy_client = "synergyc"
pattern = "^ssh.*#{port}"

pid = %x{pgrep -f #{pattern}}
%x{kill #{pid}} if pid != 0 and pid != nil and pid != ""

cmd = "su #{USER} -c \"ssh -f -N -L \
#{port}:#{@site.synergy_server}:#{port} #{@site.synergy_server}\""

# this one gets executed but nothing afterwards...
%x{#{cmd}}

pid = %x{pgrep -f #{synergy_client}}
%x{kill #{pid}} if pid != 0 and pid != nil and pid != ""

%x{su #{USER} -c "#{synergy_client} localhost"}