다음 코드는 파일을 꼬리로 관리하지 않습니다. 그것은 독자 입력을 기다리는 것입니다. 아무도 비슷한 것을 시도한 적이 있습니까?가니메드 SSH 라이브러리에서 Clojure로 파일을 꼬리 끌 수 있습니까?
(def output (ref []))
(import 'ch.ethz.ssh2.Connection)
(import 'ch.ethz.ssh2.Session)
(import 'ch.ethz.ssh2.StreamGobbler)
(import 'java.lang.StringBuilder)
(import 'java.io.InputStream)
(import 'java.io.BufferedReader)
(import 'java.io.InputStreamReader)
(let [connection (new Connection "hostname")]
(. connection connect)
(let [ok (. connection authenticateWithPassword "username" "password")
session (. connection openSession)]
(. session execCommand "tail -f filename.txt")
(let [sb (StringBuilder.)
stdout (StreamGobbler. (. session getStdout))
br (BufferedReader. (InputStreamReader. stdout))
]
(future (loop [line2 (. br readLine)]
(if (= line2 nil)
nil
(do
(dosync (ref-set output (conj @output line2)))
(recur (. br readLine))))
)
)
)
)
)
나는 이런 식으로 시도했지만 결코 작동하지 않을 수 있습니다. 지금 나는 순수한 자바로 노력하고있다. 문제는 Ganymed가 임의의 시간에 연결을 끊어 버렸고 이유를 파악할 수 없다는 것이 었습니다. 어쨌든 고마워. – Zubair