my code stock.com

Snippet options

Download: Download snippet as untitled.txt.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

private SSHConnection conexaoFtp = null;
	private Session sess = null;

public String executarFtp (String listComand, String nomeArquivo, String strCaminho) throws Exception{
	  String strPath = "cd /provdes/asap/u001/asapser1/pesquisa_msisdn\n";
	  String str_cmd = "consulta_nokia "+nomeArquivo + "\n";
      
	  String texto = "";
	  
      try {   	            
    	  
    	  
          sess = conexaoFtp.getConnectionFTP().openSession();         

          
          sess.startShell();
          OutputStream outt = sess.getStdin();          
          outt.write("cd\\ \n".getBytes());
          System.out.println("Escrever shell script");
        
          outt.write(  strPath.getBytes()  );            
          outt.write(  str_cmd.getBytes()  );
          outt.write(	"finger \n".getBytes());
                    
          java.io.InputStream stdout = new StreamGobbler(sess.getStdout());
          BufferedReader br = new BufferedReader(new InputStreamReader(stdout, "UTF-8"));
          
          export:  
        	  for(int i = 0; i < 100; i++){	  
        		  String line = br.readLine() + "\n";
        		  texto += line;
	        		   System.out.println(line);
        		  if(((texto.indexOf("Bldg.") > -1) && (texto.indexOf("TTY Idle") > -1) && (texto.indexOf("Login") > -1)) || (texto.indexOf("logged") > -1)){	        			   
        			  break export;
        		  }
        	  }
           
          br.close();
	      System.out.println("br");
	      stdout.close();
	      System.out.println("stdout");
	      conexaoFtp.close();
	      System.out.println("ftp");
	      sess.close();
	      System.out.println("sess");
	      System.out.println("conexão Fechou!");
	      
	      return texto;
	     
        
      } catch (IOException e){          
    	  e.printStackTrace(System.err);
          System.exit(2);
          sess.close();
          System.out.println("conexão fechou!");
                    
      }
  return texto;
  }
  
  
  
  String[] text = retorno.split("\n");
			for (int i = 0; i < text.length - 6; i++) {
				System.out.println(i + ": " + text[i]);
				int index;
				
				
				if (text[i].matches(".*(IMSI).*")) {
					index = text[i].indexOf("IMSI");
					acessoGsm.setImsiHLR(text[i].subSequence(index + 6,
							index + 21).toString());
				}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.