0

So I have a unix command which executes an ab-initio graph:

export AB_HOME=/opt/abinitio/installations/Saturn_Abinitio/ab_home;/opt/abinitio/installations/Saturn_Abinitio/ab_home/bin/air sandbox run /home/sp64647/Multifonds/mp/SecoreEventsDriver.mp

The command works as expected when run on an SSH client like Tectia or Putty.

But the same command when run through JSch isn't working as expected:

Here's a bit of the JSch code:

try{
          JSch.setLogger(new MyLogger());
      JSch jsch=new JSch();  

      String host=null;

      String user=getUserid();
      host="fdcgtsabnaa01d.eur.nsroot.net";
      String config =
                "Port 22\n"+
                "\n"+
                "Host foo\n"+
                "  User "+user+"\n"+
                "  Hostname "+host+"\n"
                ;



              ConfigRepository configRepository =
                com.jcraft.jsch.OpenSSHConfig.parse(config);


              jsch.setConfigRepository(configRepository);
              Session session=jsch.getSession("foo");


      String passwd =getPassword();
      session.setPassword(passwd);
      UserInfo ui = new MyUserInfo(){

          public boolean promptYesNo(String message){

            int foo = 0;
            return foo==0;
          }
      };
      session.setUserInfo(ui);
      session.connect();

      String command="export AB_HOME=/opt/abinitio/installations/Saturn_Abinitio/ab_home;/opt/abinitio/installations/Saturn_Abinitio/ab_home/bin/air sandbox run "+mainGraphPath;

      Channel channel=session.openChannel("exec");

      ((ChannelExec)channel).setCommand(command);


      channel.setInputStream(null);


      ((ChannelExec)channel).setErrStream(System.err);

      InputStream in=channel.getInputStream();

      channel.connect();

      byte[] tmp=new byte[1024];
      while(true){
        while(in.available()>0){
          int i=in.read(tmp, 0, 1024);
          if(i<0)break;
          page_message=new String(tmp, 0, i);
          System.out.print(page_message);
        }
        if(channel.isClosed()){
          if(in.available()>0) continue; 
          System.out.println("exit-status: "+channel.getExitStatus());
          break;
        }
        try{Thread.sleep(1000);}catch(Exception ee){}
      }

      if(channel.getExitStatus()!=0){
          flag=false;
      }
      channel.disconnect();
      session.disconnect();

    }
    catch(Exception e){
      System.out.println(e);
    }

The command above works perfectly with other parameters too.

Expected Output:

info : ++++ STARTED ++++ Job SecoreEventsDriver_2016-12-02-12-20-11_25100584 info : Execution host fdcgtsabnaa01d.eur.nsroot.net info : Central logging to /opt/abinitio/data/Saturn_London/admin/log/environment_operations_2016_12.log info : Raw tracking to /opt/abinitio/data/Saturn_London/admin/Multifonds/tracking/./SecoreEventsDriver_2016-12-02-12-20-11_25100584.tracking info : Input pset archived to /opt/abinitio/data/Saturn_London/admin/Multifonds/parameter/./SecoreEventsDriver_2016-12-02-12-20-11_25100584.pset info : Summary is not being collected info : Error logging to /opt/abinitio/data/Saturn_London/admin/Multifonds/error/./SecoreEventsDriver_2016-12-02-12-20-11_25100584.err info : Detailed logging to /opt/abinitio/data/Saturn_London/admin/Multifonds/log/./SecoreEventsDriver_2016-12-02-12-20-11_25100584.log info : ++++ COMPLETED ++++ Job SecoreEventsDriver_2016-12-02-12-20-11_25100584

Incorrect Output:

info : ++++ STARTED ++++ Job SecoreEventsDriver_2016-12-02-12-30-20_40632400 info : Execution host fdcgtsabnaa01d.eur.nsroot.net info : Central logging to /opt/abinitio/data/Saturn_London/admin/log/environment_operations_2016_12.log info : Raw tracking to /opt/abinitio/data/Saturn_London/admin/Multifonds/tracking/./SecoreEventsDriver_2016-12-02-12-30-20_40632400.tracking info : Input pset archived to /opt/abinitio/data/Saturn_London/admin/Multifonds/parameter/./SecoreEventsDriver_2016-12-02-12-30-20_40632400.pset info : Summary is not being collected info : Error logging to /opt/abinitio/data/Saturn_London/admin/Multifonds/error/./SecoreEventsDriver_2016-12-02-12-30-20_40632400.err info : Detailed logging to /opt/abinitio/data/Saturn_London/admin/Multifonds/log/./SecoreEventsDriver_2016-12-02-12-30-20_40632400.log info : ++++ FAILED ++++ Job SecoreEventsDriver_2016-12-02-12-30-20_40632400

How is it possible that this one command with this one specific parameter isn't running as expected through JSch but runs fine otherwise?

karansabhani
  • 137
  • 4
  • 14

0 Answers0