Dennis,

Thanks for that. Will try it later and let you know.
Definitely one I couldn't have figured out myself.

RBS

-----Original Message-----
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 15:04
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file

RB Smissaert wrote:
> How would I run these 4 commands via a .bat file or via whatever means:
>
> cd c:\test\ReadCodes
> c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
> .output testfile.txt
> select * from readcode where read_code glob 'G2*';
>
> It must be simple, but I can't see it.
>
>   
RBS,

You need to put all your sqlite shell commands in one file, say 
sqlitecmds.txt. This includes the dot commands and the SQL statements. 
So sqlitecmds.txt contains:

    .output testfile.txt
    select * from readcode where read_code glob 'G2*';

Then you need to put your DOS shell commands in another file, say 
readcode.bat. This file will contain the commnad to run sqlite and 
redirect its input to the file of sqlite commnads above. So readcode.bat 
contains:

    cd c:\test\ReadCodes
    c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db < sqlitecmds.txt

Then you tell the DOS shell (actually cmd.exe) to run the commands in 
your readcode.bat file by typing the batch file name at the command prompt.

    C:\>readcode

This will execute your batch file commands, which will run the sqlite 
shell program, which will read and execute the commands in the sqlite 
commands file, which will write its output to the file testfile.txt in 
the current directory (which will be C:\test\ReadCodes).

HTH
Dennis Cote



----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to