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

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

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.

VMStat ran everyday at midnight with the time before each entry

Trying to run a VMSTAT every 10 minutes (every 600 seconds 144 times a day) but would like to append the time at the beggining of each line.
0 00 * * * /usr/bin/vmstat 600 144|awk '{now=strftime("%T"); print now $0}' > /home/rory/rory_vmstat`date +\%d`
I keep getting a message in my mail saying:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
This works in the command line: /usr/bin/vmstat 600 144|awk '{now=strftime("%T"); print now $0}' so i'm not sure whats wrong.
I'm sure its nothing too complex, I tried switching the ' and " round but no luck. Any help will be greatly appreciated :)
You've escaped the last % character here date +\%d , you likely need to do the same with the first too:
strftime("\%T")
The issue being that cron converts % to a newline and sends the text after the % to stdin of the command, unless that % is escaped.

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.

syntax error near unexpected token `}'

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
......
......
......

Linux bat file command line arguments:unexpected EOF while looking for matching `"'

i am running a bat file in linux as following .
java -cp ../lib/qautils.jar:../lib/Log4jWrapper1.2.jar:../lib/log4j-1.2.15.jar:../lib/jaa.jar com.pcube.qa.jaa.server.JAAServer -appdir /home/alpha/jaa/bin"
but if i run above getting following error:
./runjaa.bat: line 1: unexpected EOF while looking for matching `"'
./runjaa.bat: line 2: syntax error: unexpected end of file
Will anyone suggest me , where i am doing mistake.
If i delete " at the end , saying the directiory ,/home/alpha/jaa/bin does not exists.
Assuming that what you posted is accurate, you have a trailing " on that line that doesn't match up with another quotation mark. A quotation mark opens a quoted string, so your shell is looking for the closing quote.
You don't need the quote in this example, so just remove it.

Resources