リモートマシンに.batファイルがあります。私はhttp呼び出しを通じてそれを呼び出すと思います。私はリモートマシン上で何も変更したくない。 javaとhttpを使ってそれを行う方法はありますか?http経由でリモート.batファイルを呼び出す
String command = "cmd /C start C:/Users/abc/Desktop/test.bat";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
上記は、ローカルマシン上の.batファイルを呼び出すのに適しています。私は他の方法も考慮しても構いませんが、httpを介して呼び出すことが最初の選択です。
EDIT: 私は今これを行うためにparamikoを使用しています。ただし、コマンドプロンプトでリモートコマンドを実行できません。
ssh = paramiko.SSHClient()
print "Enter the IP address"
ip = raw_input("ip>")
print "Enter the username"
user = raw_input("username>")
print "Enter the password"
pwd = raw_input("password>")
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username=user, password=pwd, allow_agent = False)
print "connection successfull"
i, o, e = ssh.exec_command("echo test") # example command
s = e.read()
if s: # an error occurred
raise RuntimeError, s
result = o.read()
print result
どういうわけか、それは例えば(CGIなどを介して)オンデマンドでこのスクリプトを実行するように構成されたhttpサーバやSSHサーバ、AllowDesktopAccessあなたは、リモートマシン上のサービスを必要とする