System copy does not work

I have asterisk running with root and try to execute

exten => _.,1,System(cp /tmp/test.txt /usr)})

the file test.txt is in the /tmp folder

but it just won’t copy, any idea why?

I try SHELL, but the same.

although “rm”, deleting a file works.

thank you!

First, your matching on _. is a bad idea.

Second, use the full path to cp (most likely /bin/cp)

Third, check permissions. Can you execute /bin/cp from user asterisk (assuming your daemon run under that user) ? Can you write to /usr ?

Afaik, this is not an Asterisk issue.

  1. System(cp /tmp/test.txt /usr)

/tmp/test.txt is the full path

  1. System(rm -f /tmp/test.txt) works fine so I think the path is correct

  2. yes, if I execute cp /tmp/test.txt /usr it works under the shell as root

  3. I think I run asterisk as root also, not as user “asterisk”. But how do I check? I compile asterisk under the root user.

Yes I know you going to say using root running asterisk is bad, but this is test and is only internal, not expose to external.

Full path for the binary: /bin/cp

ps aux | grep asterisk

And look who owns the asterisk process