Weird behaviour using executeCommand

Rudolf Visagie <[email protected]>
Newsgroups gmane.comp.java.sshtools.user
Message-ID <[email protected]>
I'm using SessionChannelClient.executeCommand to run a bash script called 
test.sh on a remote machine.

test.sh - Version I
-------------------
ls -la > temp.out

test.sh - Version II
--------------------
$ORACLE_HOME/bin/sqlplus enerbench/hcnbrn@chaos @temp.sql > temp.out

With version I, everything works find and a file temp.out is created with the 
contents of the directory.
With version II of test.sh, a file called temp.out is created, but with size 
0. If I execute test.sh from a PuTTY terminal session, everything works fine 
and the temp.out file is created.

I've got no idea what causes this, but it seems like the SSH 
connection/channel (?) is broken before the sqlplus command can finish 
executing.

Any help would be appreciated.

Thanks


Here's the a snippet of my code:

SshClient ssh = new SshClient();
ssh.setSocketTimeout(30000);

SshConnectionProperties properties = new SshConnectionProperties();
properties.setHost(extractionSetup.getSshHost().getHostName());
properties.setPrefPublicKey("ssh-dss");
  
ssh.connect(properties, new IgnoreHostKeyVerification());	  	  

PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
               
pwd.setUsername(extractionSetup.getSshHost().getUsername());	      
pwd.setPassword(extractionSetup.getSshHost().getPassword());
         
int result = ssh.authenticate(pwd);

if (result != AuthenticationProtocolState.COMPLETE) {
	throw new SSHHostException("Invalid username/password.");
} else { 
	ByteArrayInputStream bais = new ByteArrayInputStream
(extractionSetup.getSQLPlusScript().getBytes());
	ScpClient scpClient = new ScpClient(ssh, true, null);
	scpClient.put(bais, bais.available(), "temp.sql", "temp.sql");	  
		
  	
  	SessionChannelClient session = ssh.openSessionChannel();	
	  
    
  	session.executeCommand("./test.sh");
  




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.