P-James's avatar
Level 12

How to use exec to write files?

I've got a simple wrapper around SoX, a command line interface that writes a file at the specified output:

sox <input_filepath> <output_filepath>

I am trying to take a file uploaded by the user, give it the SoX treatment, then write it to storage by wrapping the above command in exec() or shell_exec.

However there is no output file. Is this expected behaviour? If yes, then how do I write a file using exec()?

0 likes
2 replies
P-James's avatar
Level 12

Update: I'm 90% certain this is because of file permissions. The exact same command works when I run manually in the console, but not when executed by the server running locally.

Now I just need to figure out the best and safest way to change these permissions...

Any tips welcome!

P-James's avatar
P-James
OP
Best Answer
Level 12

SOLUTION:

This was not a permissions issue. I wasn't using the fully qualified filepath to my Sox installation. If I install sox on a server, it's find to call sox <cmd>, but to a run a CLI tool in a local environment it needs to be C:/path/to/sox.exe sox <cmd>.

Hope this helps someone.

Please or to participate in this conversation.