0

I am using a shell script to collect data from db, the using command is given below:

$sh /tmp/testdb.sh "select * from table1;"

the query is getting by shell script is like this:

select Desktop Documents Downloads Music Pictures Public Templates Videos from table1;

the * is here taking as all files present in that directory, so How can I overcome this issue , please help me.

Shivam
  • 211
  • 1
  • 13
  • Make use of single quotes instead of double: `sh /tmp/testdb.sh 'select * from table1;'` – kvantour Jan 08 '19 at 05:17
  • 1
    The command you posted does not produce the result you report. The problem is in `/tmp/testdb.sh`, almost certainly missing quotes. See https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable – tripleee Jan 08 '19 at 05:21
  • I tried with single quote(') also but no luck, given below is the piece of shell script what I am usng: =============== #! /bin/bash params=$1 echo $params ======================= – Shivam Jan 08 '19 at 05:59
  • Yes, as pointed out by tripleee, your problem is quoting and you should use `echo "$params"`. – Benjamin W. Jan 08 '19 at 06:04
  • thanks Benjamin and triplee, it is great help, i dont know how I missed this. thanks :) – Shivam Jan 08 '19 at 07:07

0 Answers0