-3

Starting over Since I am terrible at question asking..haha

I am using a .php script that displays information to the user.

echo CHtml::tag("hr");
echo "<b>Crontab Command Line</b>:";
echo CHtml::opentag("pre");
echo "(crontab -l 2>/dev/null; echo '@reboot sleep 60 && {$coin->program} -
daemon -txindex -shrinkdebugfile') | crontab -\n";
echo "\n";
echo CHtml::closetag("pre");

when it displays on the webpage it shows as

(crontab -l 2>/dev/null; echo "@reboot sleep 60 && ${coin->program} -daemon 
-txindex -shrinkdebugfile") | crontab -\n

I am trying to correctly have it display

(crontab -l 2>/dev/null; echo "@reboot sleep 60 && variablename -daemon 
-txindex -shrinkdebugfile") | crontab -\n  

So that the user can copy and paste that line in to SSH and have it added to the users cron

its displayed to be copied to the CLI

1 Answers1

0

Change the inner double quotes to single quotes. You're not using any bash variables inside the string, so there's no need to use double quotes in the bash command.

echo "(crontab -l 2>/dev/null; echo '@reboot sleep 60 && {$coin->program} -daemon -txindex -shrinkdebugfile') | crontab -\n";

Difference between single and double quotes in Bash

If you really do need double quotes in the bash command you're writing, you can escape them.

echo "(crontab -l 2>/dev/null; echo \"@reboot sleep 60 && {$coin->program} -daemon -txindex -shrinkdebugfile\") | crontab -\n";
Barmar
  • 741,623
  • 53
  • 500
  • 612