0
I’m with a Raspbian running on a Raspberry Pi3, I’m making a system on top of it that needs the person to choose the hostname typing it into a field. And to change the hostname from rasp I need to change two files inside the folder etc. I have already managed to make these changes by command sed
, but how do I want the person to choose the hostname, I made a form by PHP and I wanted to pick up via POST this variable and pass it to the command sed
. Follows the codes.
<link rel="stylesheet" type="text/css" href="css/style.css">
<form method="POST">
<input type="text" name="hostname">
<input type="submit" name="Comentar" value=" Salvar">
</form>
<?php
if(isset($_POST['Comentar'])){
echo "botão foi clicado"."<br/>";
$SEU_HOSTNAME = $_POST["hostname"];
echo "hostname digitado: ".$SEU_HOSTNAME;
shell_exec ('
cd /etc/
sudo sed -i "s/nome/${SEU_HOSTNAME}/" hosts
sudo sed -i "s/nome/${SEU_HOSTNAME}/" hostname
');
}
?>
In doing so, only the { } appear in the modifying file. Would anyone know what that could be?
Osmar, do not post code as image, the site has support for the codes, just use them. You can do the [tour] to learn the basics of the site, read the guide of [Ask] and access the [help].
– Woss