syntax error near unexpected token `}' - linux

How can i determine what exactly the problem with my bash?
from time to time i run the script and get the following error:
download.sh: line 254: syntax error near unexpected token `}'
download.sh: line 254: `}'
but there's no '}' on line 254

You can put set -x on the second line of your bash and run it again.
#!/bin/bash
set -x
......
......
......

Related

Error appending record to a file using echo

I want to write a record using execute command stage in Datastage sequence job.
I am using below syntax.
echo "InputFileName;2021-03-25 06:54:58+01:00;AAA;Batch;FOP;FUNCTIONAL;INFO;Extra key columns sent in Key Values;201;OK;SubmitRequest;ERROR;CDIER0961E: The REST step is unable to invoke the REST service, cause=javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated;;SupplyOnhand_20210325065458;;;;0;CDIER0961E: The REST step is unable to invoke the REST service, cause=javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated;;;;12;1;2021-03-25 05:55:18+00:00;2021-03-25 05:55:33+00:00" >> Filename
Below is error I am getting.
Output from command ====>
sh: -c: line 0: syntax error near unexpected token (' sh: -c: line 0: echo Unhandled failure (-1) encountered executing command echo
I tried running this manually on linux server its working there but failing in Datastage job.
Can someone please help.
You need to escape any character that is significant to the shell, or to contain the whole string in hard (single) quotes rather than soft (double) quotes.

after install ns2: syntax error near unexpected token 'You'

after install ns2 i meet this problem
IMPORTANT: command not found
bash: /home/tuanhoang/.bashrc: line 144: syntax error near unexpected token You'
bash: /home/tuanhoang/.bashrc: line 144:(1) You MUST put /home/tuanhoang/ns-allinone-2.35/otcl-1.14, /home/tuanhoang/ns-allinone-2.35/lib,
syntax error near unexpected token 'You'
I am using ubuntu 16.04. How can i solve this problem ? Thank all of you guys for your responds
This looks like some program has put a comment in your ~/.bashrc file without properly prefixing each line with #.
Read the comment in the file and follow its instruction. Then either remove it or comment it out properly by prefixing it with #.

read input from command return error script

I have the following shell script which read data from command.
while read _ host ip time _; do
echo $host
done < <(traceroute yahoo.fr)
the above source code return script error
./traceroute_launch: line 33: syntax error near unexpected token `<'
./traceroute_launch: line 33: `done < <(traceroute yahoo.fr)'
I copied the above source code on the shell and it works. But when I run it from script file I got the above error.
What I m missing
The process substitution (<()) is bash-ism, not defined by POSIX.
So this is failing giving syntax error when you are trying to run inside the script using sh (presumably dash?), not bash.
You can have the shebang of the script set as #!/usr/bin/env bash to get the script interpreted by bash, and get the process substitution working.

Bash: Syntax Error Near Unexpected Token `(' When Using Wgrib2

Good Evening All,
I'm currently having a bash syntax issue when I try to run the following command in my terminal, the
bash: syntax error near unexpected token `('
error message pops up after I run the below code:
/mnt/grads/bin/wgrib2 /home/aaron/grads/data/sref_prob/20140530/15Z/sref.20140530.t15z.prob.grib2
-match ^(255|371|487|623|759|895|1031|1187|1343|1499|1655|1811|1967|2123|2279|2435|2591|2747|2903|3059|3215|3371|3527|3683|3839|3995|4151|4307):
-grib /home/aaron/grads/data/sref_prob/20140530/15Z/test.grib2
I realize that not many people on here probably have experience using wgrib2 but, this seems like a syntax error, not an issue with the program...
Parentheses and pipes have special meaning to the shell, you need to quote or escape them:
/mnt/grads/bin/wgrib2 /home/aaron/grads/data/sref_prob/20140530/15Z/sref.20140530.t15z.prob.grib2 \
-match '^(255|371|487|623|759|895|1031|1187|1343|1499|1655|1811|1967|2123|2279|2435|2591|2747|2903|3059|3215|3371|3527|3683|3839|3995|4151|4307):' \
-grib /home/aaron/grads/data/sref_prob/20140530/15Z/test.grib2

HIVE: How can I pass a hiveconf that contains a single quote?

I would like to pass a hive arg that contains a single quote in a string. This causes the EMR Job to fail with the following error:
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
Command exiting with ret '255'
Desired Variable:
-hiveconf "myvar=Today's a great day for a test!"
Any ideas? Thanks.
try:
SET myvar="Today's a great day for a test!";
then call it:
SELECT * FROM myTable WHERE test_today=${hiveconf:myvar}
That worked for me when I tried it, but when I try:
SET myvar=Today's a great day for a test! (withoutquotes)
I get an error. Hope this helps

Resources