나는 다음과 같은 기능이 있습니다파이썬 정규식 구문
def handleRequest(self, command, ident, ip, duration=0):
if not re.match("^[0-9]+$", ident) or not re.match("^[0-9.]+$", ip) or \
(duration and not re.match("^[0-9]+$", duration)):
print ("Unknown command")
return
if command == "DOTHIS":
reactor.callInThread(self.func, ident, "./DOTHIS.sh", ip, 0, command)
elif command == "DOTHAT":
reactor.callInThread(self.func, ident, "./DOTHAT.sh", ip, 0, command)
elif command == "DOTHAT":
reactor.callInThread(self.func, ident, "./DOTHING.sh", ip, duration, command)
elif command == "DOMORETHINGS":
reactor.callInThread(self.func, ident, "./DOMORETHINGS.sh", ip, duration, command)
else:
print ("Unknown command")
return
내 서버에 특정 스크립트를 실행하기 위해이 기능을 사용합니다. 내 문제는 실행되는 명령 (DOTHIS, DOTHAT 등)의 올바른 구문입니다. 정규식과 관련이 있어야합니다. 명령에 여러 매개 변수가있을 수 있습니다 (예 : DOTHIS 127.0.0.1).
아무리 명령을 쿼리해도 결과는 항상 "알 수없는 명령"입니다.
누구나 올바른 구문을 사용하여 명령의 예를 제공 할 수 있습니까 (몇 가지 매개 변수 포함).
감사합니다.
어떤 알 수없는 명령이 인쇄되고 있습니까? 첫 번째 또는 두 번째'print ("알 수없는 명령")' –
코드에 문제가 없습니다! 어떻게 부르는지 몇 가지 사례를 게시 할 수 있습니까? –
기본적으로 내 서버에 터미널 연결을 만들고 내가 원하는 명령을 제공합니다. 예를 들어 PING 127.0.0.1 80 (PING.sh를 실행하고 ping을 127.0.0.1 포트 80으로 시작해야 함)입니다. 또한, 나는 그것이 최초의 "알려지지 않은 명령"이라고 생각한다. – user3208125