Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to escape special character in Process facade?

I want to run a shell command with laravel Process facade method which moves all files inside a directory to another directory but i get this error:

$process = Process::run(['mv', "Test's Folder/*", 'Folder2']);

dd($process->errorOutput());
mv: can't rename 'Test's Folder/*': No such file or directory
  • create a folder with this name Test’s Folder
  • add a text file to it
  • move them to another directory

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The command is executed as expected, apparently both directories do not exist in the public directory of Laravel,. either pass a relative path or a full path.

Here is an example when both directories are in the root directory (same level as public, app. etc..), I had to use .. to step back one time. (tweak the example based on where your folders are by passing the path).

$process = Process::run(['mv', "../Test's folder", '../Folder2']);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading