java - Can we create files in Linux server from front end html page? -


I would like to know whether we can create a file from the html page in the browser in the Linux server folder? I have a shell script that creates a text file. But when I trigger this script from a browser using Ajax, it does not make any file. I have given all the permissions for the parent directory, but However, I do not see the file creative nor any errors

  test.sh "first sh" java helowword echo "t1 test" & gt; T1s if [! -f t1s] Then the echo "Shell file is not created" .. and resonates "Shell file is created .." fi ------ first.php & lt; php $ output = shell_exec ('sh test.sh'); Echo "Hello php \ r \ n"; $ Echo output; Echo "done \ r \ n"; ? & Gt; ----------- It is output from the command line: Hello PHP hello Shell file has been created for the first time .. done ---------------- This is Broser Output from: Hello php Hello sho file is not created first ..    

when If scripts are executed through your web server, then it helps to note that the environment used by your webserver is rarely similar to the environment that gives you CIA For example, the command

  sh test.sh   

creates two assumptions: sh $ Is in Python, and test.sh is in the current working directory. It is very likely that none of these is right when your webserver tries to run the command.

For better results, try to include full path in both the command and file, for example:

  shell_exec ('/ bin / sh / var / www / html / scripts / test.sh ');   

Finally, to ensure that the web user (httpd, or apache, or whatever) is allowed to execute that script, test Check executable permissions on .sh . .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -