Howto pass parameters via cakephp 3 forms to linux processes

Viewed 240

Which is the best way to pass parameters via cakephp forms to .conf files for linux processes. For example, I need to pass the 'myhostname' parameter for postfix to file main.cf.

For example:

  1. cakephp form input => myhostname = server1.example.com
  2. execute shell command => postconf -e 'myhostname = server1.example.com'

Thanx

1 Answers
  1. Just get it from the request data as described in the book here. If you don't know how to deal with modelless forms read this (assuming you're using one) and for the form helper this.

  2. Then simply execute the shell command with shell_exec and don't forget got use escapeshellcmd.

Pay attention to what you pass to the shell from the web! Mistakes here lead pretty quickly to ugly security holes.

Also I'm still teased to vote for closing this question. It's very broad, doesn't show any effort of research and is basically one of the "provide me code or tutorial" kind of question. Please do some research on your own next time. However my links should be enough to implement it.

Related