0

I have code like below

ProcessBuilder pb = new ProcessBuilder("bash", "-c",
        "  awk -f awkfile " + " file2 " + file1);

p = pb.start();
p.waitFor();
p.destroy();

pb = new ProcessBuilder("bash", "-c",
        "  awk -f awkfile " + " file3 " + outFile);
p = pb.start();
p.waitFor();
p.destroy();

pb = new ProcessBuilder("bash", "-c",
        "  awk -f awkfile " + " file4 " + outFile);
p = pb.start();
p.waitFor();

p.destroy();

awkfile has the contents

 FILENAME==ARGV[1] {vals[$1FS$2FS$3] = ",Y"; next}
      !($1FS$2FS$3 in vals) {vals[$1FS$2FS$3] = ",N"}
       {$(NF+1) = vals[$1FS$2FS$3]; print > "outFile"}

The first ProcessBuilder runs fine.The outFile has complete output (I commented out the remaining code and tested). When I include the second ProcessBuilder or third processbuilder then the outFile is incomplete. Is this a space issue or a memory issue. I do not how to find the total space allocated to my home directory. The du command results are below

   du -s /home/xxxxx
    19172   /home/xxxxx

the df command results are below

 df -k /home/xxxxx
   Filesystem                1K-blocks   Used Available Use% Mounted on
   /dev/mapper/rootvg-homelv   2064208 193068   1766296  10% /home

Is the available above 1766296 for the entire /home directory or just for my home directory /home/xxxxx

Can you please guide me as to how to get past this issue.

1
  • How is it that awkfile ignores ARGV[0]? Also, I'd recommend parameterizing the intermediate output file names (i.e. ARGV[2]) instead of hardcoding "outFile" in awkfile. Commented Dec 11, 2014 at 3:36

1 Answer 1

1

Unless quotas are enabled, you can go upto the max of what is available on your filesystem.

du -s reports the disk usage for the entire directory. I prefer the "du -sh /home/xxxx" which should report it in Mbytes, Kbytes etc.,

df -k (I prefer df -h) says how much free space is available on the entire disk (or volume) on which the filesystem is present. Note that this may include the home directories of all users.

If quotas are enabled, then you can use quota -v to see what your quotas are on each filesystem.

Looks like what you are trying to do is:

  1. take the 3 fields from the first file

  2. print out the lines from the second file with a ",Y" ending if it (the 3 fields in the second file) is also found in the first file.

or

  1. print out the lines from the second file with a ",N" ending if it (the 3 fields in the second file) is not present in the first file.

I wonder if you are using the same name for the output file as your input file. You do not say what the value of the outFile variable is in your pb. If you are trying to read and write from the same file, then the output will indeed be indeterminable.

If you are trying to get all common lines from files file1, file2, file3, file4, then i would use something like:

ProcessBuilder pb = new ProcessBuilder("bash", "-c",
    "  awk -f awkfile " + " file2 " + file1);

p = pb.start();
p.waitFor();
p.destroy();

// rename the outFile to something different. eg. outfile2.
File of= new File("outFile");
File of2= new File("outFile2");
of.renameTo(of2);

 pb = new ProcessBuilder("bash", "-c",
    "  awk -f awkfile " + " file3 " + "outFile2");
 p = pb.start();
 p.waitFor();
 p.destroy();

 // rename the outFile to something different. eg. outfile2. again.
of= new File("outFile");
of2= new File("outFile2");
of.renameTo(of2);

pb = new ProcessBuilder("bash", "-c",
    "  awk -f awkfile " + " file4 " + "outFile2");
p = pb.start();
p.waitFor();
p.destroy();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.