I am running two Ubuntu 12.04 machines. Machine A needs to start a browser (firefox or chrome) on machine B but it is not required for it to see the browser window. It just needs to start the browser and leave it. I have implemented it using JSch library (code snippet below) but this is the message that is returned - Error: no display specified
As a solution, on machine B, I set the DISPLAY variable to localhost:port or ipAddress:port where ipAddress is its own IP address and port is either 0 or some other number like 10 but it did not help.
The following works from machine A.
ssh -X <machine B ipAddress>
$firefox
I am running Windows 7 as host and two Ubuntu 12.04 (one 32 bit another 64 bit) virtual machines on Virtualbox with a bridged network.
Code:
JSch jsch = new JSch();
Session session = jsch.getSession(user, ipAddress, 22);
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
ChannelExec channelExec = null;
channelExec = (ChannelExec)session.openChannel("exec");
String command = "firefox -p project001 http://www.google.com";
channelExec.setCommand(command);
String port = command.substring(20, 21); // which is "1"
String display = ipAddress + ":" + port;
channelExec.setEnv("DISPLAY", display);
//channelExec.setXForwarding(false);
channelExec.setInputStream(null);
InputStream err = channelExec.getErrStream();
InputStream in = channelExec.getInputStream();
channelExec.connect();
Any advice? Would appreciate any help either using JSch or anything else.
Update: If I update the command to run firefox in the background, it runs, except I cannot bring it to show the browser window.