Hi folks, Im hoping somebody here can assist me with this very nub problem that Im having.
Im trying to take some data from a web page (basic form) and once submitted use that data to write a bash script (for linux) that can be actioned at a later date. This didnt seem like it would be hard, but I cant get it to cooperate at all.
I cant get the php page to write any string that contains an argument (or so it seems at least).
For example a snippet:
//Declare variable names retrieved from previous form
$Fn = $_POST["Fname"];
$Ln = $_POST["Lname"];
$ID = $_POST["IDnum"];
//Define the data file name and location
$filename = "StaffFile";
//Open the data file in write mode
$file = fopen($filename, "w") or exit ("Unable to open $filename");
//write the bash script using the information pulled from the form
$DATA = "if [ USER = "root" ]; then";
fwrite($file, $DATA);
fclose($file);
The above code will not write the "If [ USER = "root" ]; then" to a file. It will if I remove any operators from the string, but then it wont be much of a script if I do that.
Is there any way to create a file in this manner?
Also on a similar topic, the script Im wishing to create is obviously much longer than the snippet provided, can the whole script be referenced at once as a string or does it need to taken line by line?
I thank you in advance for your time.
Cena.