Skip to content
Snippets Groups Projects
Commit f1e23470 authored by tjc's avatar tjc
Browse files

remote ssh exec in working dir

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3644 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent d27c2dac
Branches
Tags
No related merge requests found
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgram.java,v 1.6 2005-08-17 17:03:06 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgram.java,v 1.7 2005-09-05 17:37:49 tjc Exp $
**/
package uk.ac.sanger.artemis;
......@@ -30,6 +30,7 @@ import uk.ac.sanger.artemis.io.EntryInformation;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.DocumentEntry;
import uk.ac.sanger.artemis.io.Qualifier;
import uk.ac.sanger.artemis.components.filetree.RemoteFileNode;
import java.io.*;
import java.text.*;
......@@ -41,7 +42,7 @@ import java.util.Enumeration;
* and contains methods for invoking it.
*
* @author Kim Rutherford
* @version $Id: ExternalProgram.java,v 1.6 2005-08-17 17:03:06 tjc Exp $
* @version $Id: ExternalProgram.java,v 1.7 2005-09-05 17:37:49 tjc Exp $
**/
public class ExternalProgram
......@@ -149,9 +150,38 @@ public class ExternalProgram
if( System.getProperty("j2ssh") != null &&
(getRealName().indexOf("blast") > -1 || getRealName().startsWith("fast")) )
{
String [] args = { "-f", file_of_filenames.getPath(),
"-cmd", getRealName(),
"-d", getProgramOptions()};
final Feature this_feature = features.elementAt(0);
Entry entry = this_feature.getEntry();
String [] args;
if(((DocumentEntry)entry.getEMBLEntry()).getDocument()
instanceof RemoteFileDocument)
{
RemoteFileDocument nodeDoc =
(RemoteFileDocument)(((DocumentEntry)entry.getEMBLEntry()).getDocument());
RemoteFileNode node = nodeDoc.getRemoteFileNode();
String wdir = node.getRootDir()+"/"+node.getFullName();
int index = wdir.lastIndexOf("/");
wdir = wdir.substring(0,index);
args = new String[9];
args[0] = "-f"; args[1] = file_of_filenames.getPath();
args[2] = "-cmd"; args[3] = getRealName();
args[4] = "-wdir"; args[5] = wdir;
args[6] = "-d"; args[7] = getProgramOptions();
args[8] = "-keep";
}
else
{
args = new String[6];
args[0] = "-f"; args[1] = file_of_filenames.getPath();
args[2] = "-cmd"; args[3] = getRealName();
args[4] = "-d"; args[5] = getProgramOptions();
}
uk.ac.sanger.artemis.j2ssh.SshPSUClient ssh =
new uk.ac.sanger.artemis.j2ssh.SshPSUClient(args);
......
......
......@@ -65,11 +65,12 @@ public class SshPSUClient extends Thread
private String bsub = null;
private String logfile = null;
private String db = null;
private String wdir = "/nfs/pathscratch1/scratch";
private String wdir = null;
//
private SshClient ssh;
private String user;
private boolean keep = false;
public SshPSUClient(String args[])
{
......@@ -90,6 +91,8 @@ public class SshPSUClient extends Thread
db = args[i+1];
else if(args[i].equals("-wdir") && i < args.length-1)
wdir = args[i+1];
else if(args[i].equals("-keep"))
keep = true;
}
}
......@@ -102,9 +105,6 @@ public class SshPSUClient extends Thread
{
String program = cmd;
// get properties from j2ssh.properties
Properties settings = getProperties();
boolean completed = false;
try
{
......@@ -113,7 +113,7 @@ public class SshPSUClient extends Thread
if(ssh == null)
return;
completed = runBlastOrFasta(ssh, program, settings);
completed = runBlastOrFasta(ssh, program);
// Quit
//ssh.disconnect();
......@@ -212,7 +212,7 @@ public class SshPSUClient extends Thread
db = "%uniprot";
}
if(settings.getProperty("wdir") != null)
if(wdir == null && settings.getProperty("wdir") != null)
wdir = settings.getProperty("wdir");
if(cmd != null)
......@@ -240,9 +240,11 @@ public class SshPSUClient extends Thread
* Run fasta or blast on the server ssh'ed into
*
*/
private boolean runBlastOrFasta(SshClient ssh, String program, Properties settings)
private boolean runBlastOrFasta(SshClient ssh, String program)
throws IOException
{
Properties settings = getProperties();
// prompt for local listfile
if(listfilepath == null)
{
......@@ -268,11 +270,12 @@ public class SshPSUClient extends Thread
try
{
if(!keep)
wdir = wdir+"/"+user;
sftp.mkdir(wdir);
wdir = wdir+"/"+program+"/";
sftp.mkdir(wdir);
sftp.mkdir(wdir);
sftp.put(filepath, wdir+filename);
}
catch(IOException ioe)
......@@ -335,8 +338,12 @@ public class SshPSUClient extends Thread
// System.out.println(os.toString());
sftp.get(outputfile, filepath+".out");
if(!keep)
{
sftp.rm(outputfile);
sftp.rm(wdir+filename);
}
session.close();
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment