Phing Exec Task and Argument Escaping
Recently I needed to run a script on server via SSH. To automate things I wanted to execute the script via Phing. The command I wanted to execute looked like this:
ssh myuser@remotehost "/home/myuser/bin/script.sh -d /tmp"
Executing the command above via the Phing Exec returned a wired error. After diving deep into the Phing sources I realized that Phing tries to escape the arguments which at some point simply messes things up. I spend some more time debugging things and came across the escape attribute of the exec task which in the end help me to fix my problem. As it turns out, this is how you need to invoke the exec task in this case:
<exec executable="ssh" escape="true"> <arg value="myuser@remotehost" /> <arg value="/home/myuser/bin/script.sh -d /tmp" /> </exec>Tags: Phing, PHP