2017-05-10 1 views
-2

안녕하세요 저는 현재 자신의 소프트웨어를 사용하여 Raspberry Pi로 로봇을 제어하고 있습니다. 나는 HTML 코드에 ssh를 삽입 할 수 있는지 궁금 해서요. 그래서 사용자가 Pi의 IP 주소를 입력하면 ssh를 통해 pi에 연결됩니다.웹 사이트에서 SSH를 사용하십시오.

그러면 버튼을 클릭 할 때 ssh를 통해 명령을 보내고 싶습니다. E.G. 뒤로.

그러면 데이터를 가져올 수 있다면 GPI 핀을 파이썬 코드를 통해 라즈베리 파이에서 제어 할 수 있습니다. 아래 그림과 같이

내가 제어 코드의 일부를 썼다 :

<html> 
<head> 
    <style type="text/css"> 
     #commands{ 
      text-align: center; 
      color: FF8300; 
      font-size: 100px; 
     } 
     .controllbox{ 
      width: 610px; 
      margin: 0 auto; 
     } 
     #arrowUp{ 
      text-align: center; 
      position: static; 
     } 
     #arrowRight{ 
      text-align: right; 
      position: static; 
      margin-top: 0; 
     } 
     #arrowDown{ 
      text-align: center; 
      position: static; 
     } 
     #arrowLeft{ 
      text-align: left; 
      position: static; 
      margin-top: -200px; 

     } 
     #stop{ 
      width: 120px; 
      height: auto; 
      margin: 0 auto; 
      margin-top: -65%; 
      margin-left: 34%; 
      text-align: center; 
      position: static; 


     } 
    </style> 
</head> 
<body> 

    <h1 id="commands">Controll Me!!</h1> 
    <div class="controllBox"> 
     <div id="arrowUp"><img src="arrowUp.jpg" class="controll" id="button1"></div> 
     <div id="arrowRight"><img src="arrowRight.jpg" class="controll" id="button2"></div> 
     <div id="arrowLeft"><img src="arrowLeft.jpg" class="controll" id="button3"></div> 
     <div id="arrowDown"><img src="arrowDown.jpg" class="controll" id="button4"></div> 
     <div id="stop"><img src="stop.jpg" class="controll" id="button5"></div> 
    </div> 
<script type="text/javascript"> 

     document.getElementById('button1').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Foward' 
     } 
     document.getElementById('button2').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Right' 
     } 
     document.getElementById('button3').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Left' 
     } 
     document.getElementById('button4').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Backwards' 
     } 
     document.getElementById('button5').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Stop' 
     } 

    </script> 
</body> 

당신이나 내가 내 머리를 철수하고 같은 비슷한이 작업을 수행하는 방법을 알고 있다면 그것은 크게 감사합니다

, 내가 어떻게하는지 알아 내려고.

여러분의 도움에 많은 감사드립니다. James.

+1

https://en.wikipedia.org/wiki/Web- 그것을 실행하는 명령 문자열을 포맷합니다 based_SSH – CBroe

+0

https://github.com/aluzzardi/wssh – Bergi

+0

또는 https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo?hl=ko –

답변

2

HTML 또는 자바 스크립트 (JS 일 수도 있지만 더 많은 노력이 필요함)를 통해 SSH 명령을 실행할 수 없습니다.

더 안전하고 관리하기가 쉽기 때문에 PHP 나 Python 또는 다른 스크립팅 언어를 사용하여 웹 서버에 양식을 제출하는 것이 좋습니다.

그러면 웹 서버가 SSH를 호출하여 명령을 실행해야합니다.

예를 들어

:

POST: example.com/forward.php?inst=backward&ip=1.2.3.4 

를 다음 PHP는 SSH를 실행 한 다음 간부 인()

+0

고마워요. 나는 진짜 초보자입니다. 이것과 모르겠다 PHP는 이것보다 더 쉽게 당신이 나를 쉽게 도와 줄 수있는 다른 무엇이있다. –