Search code examples
database-administrationscripting

don't understand atquery command script


I'm using a big-data database. in one of it's tutorial it has recommended me to use below bash scripts if order to running queries:

#!/bin/sh
# this will launch the real atquery program with the given .sql file
# note: please adjust INSTALLNAME, HOST and PORT to reflect your installation
/home/lms/INSTALLNAME/atquery HOST:PORT $*

Then, start runnable .sql files like the following:

#!/usr/local/bin/runatquery
select count(*) from mytable during all

I don't understand $* part of the /home/lms/INSTALLNAME/atquery HOST:PORT $*. what will $* does? this was suppose to create a shell script in order to run a query, but another problem is this is two file (I supposse because we two #! in that) so how will this two file help me to run queries? I suppose if we had a script with below code in it, it would do this work to me better and without confusion:

!/bin/sh

/home/lms/INSTALLNAME/atquery HOST:PORT -e 'select count(*) from mytable during all'

Solution

  • You have to create that script as recommended (you didn't include that, probably right before the script) as a file with the executable bit on, and changing INSTALLNAME, HOST and PORT as per your system requirements.

    The $* expands to all parameters received by the script.

    The second file is an example of how you can create scripts that are run by runatquery.