I'm trying to run a command at the command prompt and if one of the values includes a single quote it doesn't run correctly.
The command I'm using is :
lxc-attach -n test -- bash -c 'echo 'abcd1234' > /home/rocket/test.log'
This will complete without issue and abcd1234 is written to the test.log correctly.
However if I run the command with abcd'1234 then the command doesn't update the log file.
lxc-attach -n test -- bash -c 'echo 'abcd'1234' > /home/rocket/test.log'
I've tried escaping the ' with \ but that hasn't helped.
Could someone advise how to get this to run.
Thanks
UPDATE I'm actually running this from a PHP page and using SSH to update the server. The actual command being run is:
$update = "echo $password | sudo -S lxc-attach -n $server -- bash -c 'echo \"$value\" >> /home/rocket/test.log'";
$ssh->exec( $update );
Where $value may contain a single quote.
What I would do:
or: