有没有人知道一种简单的方法来创建一个可以连接到telnet服务器的脚本,做一些通常的telnet东西,然后注销?我正在处理不熟悉telnet的用户以及他们需要运行的命令.我想要的只是让他们双击一个脚本,并让该脚本自动执行它们的命令.
您可能想知道,"用户使用什么平台?" 它们将在Windows和Linux上运行.可以接受Perl,Java或Python等语言的实现.我看到Perl有一个Net :: Telnet模块.有人用过吗?
我理想的解决方案是创建两个脚本文件.用于Windows的BAT文件和用于Linux的shell脚本.虽然这会使双重维护成为一个问题,但这意味着我不必在每台机器上安装Perl/Java/Python /等等.不幸的是,我还没有看到任何方法来自动化批处理文件或shell脚本的telnet会话.
谢谢.
我想编写一个Java程序,在VirtualBox客户机中启动程序(例如:Firefox).主机是Windows,客户端是Ubuntu.根据SDK文档,应该可以这样做.这是我基于我在文档中看到的Java尝试(假设VM启动并运行):
String machineName = "MyMachine";
String url = "http://localhost:18083";
String user = "";
String passwd = "";
VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
mgr.connect(url, user, passwd);
IVirtualBox vbox = mgr.getVBox();
System.out.println("Running VirtualBox version " + vbox.getVersion());
IMachine machine = vbox.findMachine(machineName);
ISession session = mgr.getSessionObject();
machine.lockMachine(session, LockType.Shared);
IConsole console = session.getConsole();
IGuest guest = console.getGuest();
IGuestSession guestSession = guest.createSession("bob","password", "", "");
guestSession.processCreate("/usr/bin/firefox", null, null, null, 0L);
session.unlockMachine();
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到:
Exception in thread "main" org.virtualbox_4_2.VBoxException: VirtualBox error: The session is not locked (session state: Unlocked) …Run Code Online (Sandbox Code Playgroud)