I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks
sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `./billdatecalc.sh <SetList>50/10000////D4B790E1////3/0</SetList>'
The "param" variable carries the following data "<SetList>50/10000////D4B790E1////3/0</SetList>"
awk '
/SetList/ {
param = $0
cmd = "./billdatecalc.sh "$param""
system(cmd)
}
' touch.xml
too many qoutes:
cmd = "./billdatecalc.sh \"$param\""
Thanks for the input. The syntax issue is solved. However I don't see any data being passed in the parameter and it always seems to be empty. Any idea ?
The system
function if just for execution and only provides the return code, otherwise try using the "cmd" | getline
construct instead...
Yoda
May 1, 2013, 11:13am
5
Also awk variables are not referenced with a dollar sign $
Try this:
param = $0
cmd = "./billdatecalc.sh " param
cmd | getline var
close (cmd)
print var
Using this part of the code again leads to syntax error
sh: -c: line 0: syntax error near unexpected token `newline'
cmd = "./billdatecalc.sh " param
I tried this one , the syntax issue disappeared however no data being passed in variable "param".
param="<SetList>5/315/3///////NONE/0</SetList>"
cmd = "./billdatecalc.sh \"$param\""
I tried directly substituting the data directly as follows and the shell script is able to read the data being passed.
cmd = "./billdatecalc.sh \"<SetList>5/315/3///////NONE/0</SetList>\""
It appears that there is something wrong the way the variable being passed in the shell script
Any idea ? Thanks
Try
cmd="./billdatecalc.sh " param
You may want to avoid using a relative path name...
It doesn't make any difference as I am still getting the syntax error
sh: -c: line 0: syntax error near unexpected token `newline'
What is your OS and version?
What is in billdatecalc.sh
?
What happens when you use
cmd="echo xxx " param
Does it work then?
OS and version is
Linux 2.6.9-67.ELlargesmp #1 SMP Wed Nov 7 14:07:22 EST 2007 x86_64 x86_64 x86_64 GNU/Linux
The shell script reads the input parameter being passed, checks for a particulat pattern and if found replace that pattern with a different value.
billdatecalc.sh
I tried this code
cmd="echo xxx " param
and still the same syntax error
What does
cmd="./billdatecalc.sh \"" param "\""
produce?
Otherwise could you post billdatecalc.sh
--edit--
OK you say even cmd="echo xxx " param
produces the wrong results, odd..