Adam_G Adam_G - 1 month ago 7
Java Question

-bash: syntax error near unexpected token `('

I'm trying to run the query below in Terminal on OSX. It keeps returning:

-bash: syntax error near unexpected token `('


I'm sure I'm overlooking something very dumb. If someone could point me in the right direction, I'd appreciate it. The command includes the SQL query for the program to execute:

java -Xmx16g -cp .:lib/* edu.cuny.util.VectorToInstancesConverter train HandednessJ48 “SELECT * FROM collection1.Session1 WHERE Subj_Id!=402 and Subj_Id not in ( select Subj_id from collection1.Session2) AND Subj_Id IN ( SELECT Subj_Id FROM collection1.userdata WHERE 'DominantHand' = 'l' OR 'DominantHand' = 'r')” 12 J48

Answer

The problem is when you use " bash tries to evaluate anything within it instead you should use ', try this:

java -Xmx16g -cp .:lib/* edu.cuny.util.VectorToInstancesConverter train 
HandednessJ48 'SELECT * FROM collection1.Session1 WHERE Subj_Id!=402 
and Subj_Id not in ( select Subj_id from collection1.Session2) AND 
Subj_Id IN ( SELECT Subj_Id FROM collection1.userdata WHERE 
'DominantHand' = 'l' OR 'DominantHand' = 'r')' 12 J48

or as @bhesh has specified you can delimit the characters which bash will try to evaluate :

java -Xmx16g -cp .:lib/* edu.cuny.util.VectorToInstancesConverter train 
HandednessJ48 "SELECT * FROM collection1.Session1 WHERE Subj_Id!=402 
and Subj_Id not in \( select Subj_id from collection1.Session2\) AND 
Subj_Id IN \( SELECT Subj_Id FROM collection1.userdata WHERE 
'DominantHand' = 'l' OR 'DominantHand' = 'r'\)" 12 J48
Comments