0

I need to create a bash file with PHP using the phpseclib library. This is the code I am using now:

   $ssh->exec("cat > $sPath$sSavingCode <<EOF
screen -dmS $1 java -Xincgc -Xmx200M -jar craftbukkit-1.4.7.jar nogui
        ");

The code works, and the file saves, but it skips the "$1". instead, it makes a file with two spaces between -dmS and java.

How can I make it so the $1 is written to the bash file?

Thanks

EDIT

This is the whole function:

    {
        $sPath = "minecraft/servers/".$user."/";
        $sSavingCode = "start.sh";
        $ssh->exec("cat > $sPath$sSavingCode <<EOF
screen -dmS $1 java -Xincgc -Xmx200M -jar craftbukkit-1.4.7.jar nogui
        ");
    }

$sPath and $sSavingCode are PHP variables, and the $1 is a bash variable that needs to be in the script.

4

1 回答 1

3

Why not assigning your command to a simple variable?

    $command = ' screen -dmS \$1 java -Xincgc -Xmx200M -jar craftbukkit-1.4.7.jar nogui'

    $ssh->exec("cat > $sPath$sSavingCode <<EOF
$command
        ");
于 2013-03-30T20:56:52.363 回答