0

I'am currently changing our system to use another server for getting file (files generated for tracking something, not important). This system is based on java, and the code for getting these files are using Linux commandos. The code for getting these files are:

session = connection.openSession();
session.execCommand("ls -B -A " + filelocation);
output = new BufferedReader(new InputStreamReader(new StreamGobbler(session.getStdout()), "UTF-8"));

This did however work on our original server (x86_64 GNU/Linux), but does not work on the "new" server (SunOs 5.10 Generic January). When running this command on the SunOS server i get:

ls: illegal option -- B
usage: ls -1RaAdCxmnlhogrtuvVcpFbqisfHLeE@ [files]

I am far from well versed with with the commandline, and I have not written the original code. But this is what i figured

-A, --almost-all           Do not list implied . and ..
-B, --ignore-backups       Do not list implied entries ending with ~

Is there an optional way of getting this to work on the SunOS server?

EDIT

Checking each String read if line.endsWith("~");

while ((outputString = output.readLine()) != null) {
    if(!outputString.endsWith("~")){
         fileList.add(outputString);                     
    }
}
Jinxen
  • 83
  • 1
  • 8

1 Answers1

0

Either you can write a shell script new_ls calling ls and removing the lines that end with "~"

Or when you process the results in java you can also ignore lines read from the BufferedReader by checking each String read if line.endsWith("~");

GerritCap
  • 1,606
  • 10
  • 9
  • I think im gonna stay away from writing a shell scripts. But when checking each String if the line ends with ~, does that mean that I should remove -B in the command: session.execCommand("ls -A " + filelocation); ? Ive also edited the post for more code information, is this the usage of ends with you mean? – Jinxen Sep 13 '13 at 08:25