I am trying to create a file automatically through PHP, but with the unix cat commands through SSH. I can create a file in the directory I am in, but I want to create a file in a different directory. This is the code that creates the file in the directory I am in:
$sPath = "/minecraft/servers/";
$sSavingCode = "server.properties";
echo $ssh->exec("cat >".$sSavingCode." <<".$sPath."
test");
This code gives this error, but it creates the file in the directory I am in:
bash: line 1: warning: here-document at line 0 delimited by end-of-file (wanted `/minecraft/servers/’)
I just need a way to create the file in a different directory. Thanks
You used the path (
$sSavingCode) as the delimiter for the heredoc statement. You should try the following statement. It uses the literalEOFas the delimiter for the heredoc section: