List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 17 2002 3:50am
Subject:Re: running sql commands from a shell
View as plain text  
At 11:13 +1000 1/17/02, Mr Aaron Brandis wrote:
>Hi everyone
>
>This is the first time I have posted to this list and I was wondering if
>someone could answer my question.  I know you can run commands from a
>shell prompt (such as unix...) like:
>
>shell> mysql -e 'SELECT * FROM table' database
>
>for a simple select query and
>
>shell> mysqlimport --local database table.txt
>
>to import information from a text file. 
>
>I was just wondering how (and even if you can) set up a pager and write
>to a file from the shell.  I can do it from the mysql command prompt
>like this:
>
>mysql> pager cat /home/aaron/tube.txt;
>mysql> select Run from tubes;
>
>This will put the result of the query into tubes.txt  So does anyone
>know if i can do this from the shell prompt??

Writing to a file and paging the output are normally mutually exclusive
activities.  Why do you want to do this?

If you just want to save the output in a file, you don't need to use
a pager.  Just do this:

mysql -e 'select Run from tubes' database > /home/aaron/tube.txt

And if you want the usual boxed-table output (rather than tab-delimited,
which is what you normally get when redirecting the output to a file),
do this instead:

mysql -t -e 'select Run from tubes' database > /home/aaron/tube.txt


>
>Thanks alot for your help
>
>Aaron

Thread
running sql commands from a shellMr Aaron Brandis17 Jan
  • Re: running sql commands from a shellPaul DuBois17 Jan
  • Re: running sql commands from a shellnod17 Jan