0
쉘 명령에서 변수를 보내고 화면에 출력을 얻으려고합니다. 화이트 필자는 ping -c 5 google.com
을 ping 할 때 작동하지만, 넣을 변수가 $username
인 경우 그렇지 않습니다. 변수가 작동하지 않는 이유는 무엇입니까? 당신은 작은 따옴표를 사용하는PHP + 쉘 스크립트
<html>
<head>
<title>Form</title>
</head>
<body>
<form method="post" action="7.php">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
<?php
$username = $_POST["username"];
$result = shell_exec('ping -c 5 $username');
echo "<pre>$result</pre>";
?>
이이 ** 엄청난 ** 보안 위험을 사용해야합니다. '내가 게시하면 어떻게됩니까? rm -rf /'를 스크립트에 추가 하시겠습니까? – DaveRandom
정보 주셔서 감사합니다! 나는 그것으로 무엇인가하려고 노력할 것이다 – dend