Skip to content
Advertisement

PHP string concat with slashes and variables

I am trying to exec an rclone command via a PHP script. The plain text version of the call looks like this:

rclone copy /media/storage/Events/01//999/001 events:testing-events-lowres/Events/01/999/001 --size-only --exclude /HiRes/* --include /Thumbs/* --include /Preview/* -P --checkers 64 --transfers 8 --config /home/admin/.config/rclone/rclone.conf -v --log-file=/www/html/admin/scripts/upload_status/001.json --use-json-log

But when I run it, I’m missing a bunch of stuff and getting divide by 0 errors.

exec("rclone copy $baseDir/".$mainEventCode/".$eventCode".  " events:testing-gfevents-lowres/Events/01/$mainEventCode/".$eventCode/" --size-only --exclude /HiRes/* --include /Thumbs/* --include /Preview/* -P --checkers 64 --transfers 8 --config /www/html/admin/scrips/rclone.conf -v --log-file=$directoryName/$eventCode.json --use-json-log");

I’ve tried a number of other combinations of / and ” and can’t quite get it dialed in.

Advertisement

Answer

If the below is working fine

rclone copy /media/storage/Events/01//999/001 events:testing-events-lowres/Events/01/999/001 –size-only –exclude /HiRes/* –include /Thumbs/* –include /Preview/* -P –checkers 64 –transfers 8 –config /home/admin/.config/rclone/rclone.conf -v –log-file=/www/html/admin/scripts/upload_status/001.json –use-json-log

Then below is the related PHP code, assuming your variables will contain correct values. You are doing some mistake while concatenating, not using proper . (dots) and ” (quotes).

exec(“rclone copy “.$baseDir.”/”.$mainEventCode.”/”.$eventCode.” events:testing-events-lowres/Events/01/”.$mainEventCode.”/”.$eventCode.” –size-only –exclude /HiRes/* –include /Thumbs/* –include /Preview/* -P –checkers 64 –transfers 8 –config /www/html/admin/scrips/rclone.conf -v –log-file=$directoryName/”.$eventCode.”.json –use-json-log”);

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement