-1

I am developing a web app, wherein I am using shell script as my back end(which has an embedded awk script) and Java as my front end . I am using Process Builder to call the shell script program . Strangely, my awk script which is inside my shell script is not getting executed . Am I going wrong some where ... Could you ppl plese share your views regarding this .

The shell script as typed in a comment below.

#!/bin/bash
FileA=$1
FileB=$2
awk -v FileA="$FileA" '{print $0 >> FileA;}' "$FileB"
Seth Robertson
  • 30,608
  • 7
  • 64
  • 57
NandaKumar
  • 905
  • 4
  • 15
  • 19
  • Provide more information, source code, examples, errors. Is the shell script being called successfully? If you run the shell script from the command line does it worK? – Seth Robertson Jul 23 '12 at 00:30
  • Yes when i run the shell script it does work .. I am not getting any kind of error if I call the shell script from Java.. The desired function of awk script is not performed when I cal through Java – NandaKumar Jul 23 '12 at 00:52
  • In your shell script, add lines like: `exec >/tmp/out 2>&1; set -x` this will stuff all output into the file /tmp/out and then show you each command as it is run. Run via shell to test that it works, then `rm /tmp/out` and run via Java. – Seth Robertson Jul 23 '12 at 01:09
  • #!/bin/bash FileA=$1 FileB=$2 awk -v FileA="$FileA" '{print $0 >> FileA;}' "FileB".. This is the simple program that I am using but I am not getting the expected results and also no errors – NandaKumar Jul 23 '12 at 01:36

1 Answers1

0

Trying to type programs to each other in comments is silly. I've edited your question to include what I deciphered your shell script to be. I've created this answer to document what I'm asking you to modify the program to. Please supply the output (in your question) as seen in /tmp/out for both executing this script from a shell and from the java program.

BTW, are you running the java program as your own user or might the java program be executed by a different user id causing permission problems when you attempt to append to the file.

#!/bin/bash
rm -f /tmp/out
exec >/tmp/out 2>&1
date
set -x
printenv
which awk
FileA="$1"
FileB="$2"
ls -l "$FileA"
id
awk -v FileA="$FileA" '{print $0 >> FileA;}' "$FileB"

Make sure you post a comment to me when you have updated your question.

Seth Robertson
  • 30,608
  • 7
  • 64
  • 57