PHP + linux bash script

The_Lishaczek

New member
Hey there, I must make a web GUI for my certificate-generating app / a major school project / assignment / practical leaving exam.

This script works neatly on a specific Linux machine without major flaws (CLI script)

However, the only way I could think of to tackle the GUI task was a PHP form with its values getting sent to the bash script as arguments.

I can only use sudo (full privileges for sudo, it´s a school-owned and managed VM)

I could get the form inputs but I could not get them to the original script, nor any variation of it, when I tried it myself.

I know it´s not just a PHP issue as I am using sudo on almost every line (can´t do root access, because it is a school-owned VM) but I also have to consider some security measures.

I tried using escapeshellarg, exec, shell_exec ... (dunno if is even possible to achieve something with it in my case)

There´s the full Linux script as well as an index file.

Every bit of help is much appreciated, be it the code itself or the hell called Linux aftermath.
 

Attachments

You can make few trick to achive that:
You can pass the password for root using:
Code:
echo password | sudo -S command
You can also put the output to the file:
Code:
SomeCommand 2>&1 ./output.log
You can also run the command in the backgroud, so you can easly read the file and parse new content from the output file instantly:
Code:
(command --with --parameters &)

If you want to get more detailed or more matched answer to yours files, please put your code inside the code block or share a link to some service like github gist, where everyone can easly read the code
 
Hello, thanks for the reply.

Seems like I figured it out earlier today, at least for the most part.

Thank you either way, I´ll return if something else pops up.
 
Back
Top