SQLite in AppleScript? - macos

I have a Windows app called via Shell from MS Word that reads and writes to Sqlite. I'm porting it to Mac. On windows I have a batch file:
SQLite3.exe pathtodb\databasename <sqlitecommands.txt
This batch calls the Sqlite command line program, attachs the database, and reads the command from sqlitecommands.txt. The sqlitecommands is dynamically modified(by Word VBA) to read (Select) Write (Update) to/from the database.
What is the format of an applescript to do the same thing in Mac OSX?

The following AppleScript creates a one-line shell script with sqlite syntax and executes it:
set sql to "sqlite3 ~/desktop/test.db 'insert into \"test\" values(\"hello world\",\"666\");'"
do shell script sql
You can use this example to create your own scripts dynamically.

Related

TeraTerm execution through the Windows command prompt

I have some basic simple two character commands to be executed in TeraTerm.
Is there a way to execute the same TeraTerm commands through a Windows command prompt? This will overcome my dependency to open TeraTerm and then running, commands. I can directly write some .bat file to execute my short commands.
Assuming that your commands are for teraterm, and not for the OS of your device connected via teraterm, you can save your commands into a .ttl file (using notepad or whatever). You can still make it work if the commands are for the OS (using a command line or whatever in the shell of the OS program connected), but you will have to make extra commands to navigate to it.
Using the .ttl file, you can make a .bat file that does two things:
cd C:\Program Files\teraterm
TTPMacro C:\[point to .ttl file]
This won't prevent teraterm from opening, because if you script involves you interfacing with teraterm at all, it'll open unless you add /V after TTPMcro. However, it will be a hands free experience.
You can find out more about deploying the macro here: https://ttssh2.osdn.jp/manual/en/macro/
And a list of all the commands here: https://ttssh2.osdn.jp/manual/en/macro/command/index.html
And if you need special characters for navigation (ctrl+s, etc), the ASCII code table is here: https://ttssh2.osdn.jp/manual/en/macro/appendixes/ascii.html
Hope that helps!
If it's only several basic commands, you can make it without the ttl file by using TTermPro in lieu of TTPMacro.
cd C:\Program Files\teraterm
TTERMPRO /C=1 (connect thru serial com 1)
TTERMPRO etc etc
The syntax for command line using TTERMPRO can be found here: https://ttssh2.osdn.jp/manual/en/commandline/teraterm.html

Toad for oracle - open automatically generated script

I have a script generator in .bat file. This .bat generates a sql script and saves it on disk.
Is there any option to open automatically this script in toad? Also if there is already toad application running to open this script in running toad instance?
You can pass the filename to Toad as a command line argument.
Example: >Toad.exe "C:\My Scripts\MyFile.sql"
On the Startup page in Toad's Options there is an option to only allow multiple instances of Toad. If that is unchecked the above call will reuse an open instance of Toad and open your script.

How to execute oracle query that was saved in a .txt file

I have too long oracle query that I saved in .txt file. and I am using Toad to execute that..
some it is too difficult to open such large code file and execute the code..
Is there any query that I can execute and give path to file that execute the code placed in that file.
For example something like that:
Execute code C:/My Code/code1.txt;
If you have a TOAD locally installed, you can use
#C:/My Code/code1.txt
This works from an editor tab in Toad 12.10.0.30 with the slashes going either direction and pressing F5 or "execute as script". The file can end in .txt or .sql but it is better to use .sql extension as it represents what the file contains.
It also works when using other programs such as sqlplus or sqlDeveloper

Windows Batch files and SQLite

When creating a batch file in Windows for SQLite, can the batch file run any commands after it has entered the SQLite shell? Or is it only possible to add command line options?
What I want to do is create a batch file that that starts SQLite and loads the database I want. Then it runs several SQLite commands and then quits.

using google-apps-script to try to create a bash shell script from spreadsheet

We are trying to generate a bash shell script for use on a Linux system from values stored in a Google spreadsheet and we are having difficulties.
I can create the script contents fine and save the resultant file to Google drive but the problems come about when I try to use the file on a Linux box. When the file is downloaded as plain text the encoding is set to UTF-8 which Linux thinks is a binary file when I try to execute it. The other problem we are having is the line endings are forcibly set to the host PC which is a windows box so I get CRLF not LF as required by the Linux machine. I was wondering if there was anyway in Google app scripting to forcibly give me ASCII encoding and UNIX line ending somehow. I'd rather not have to pipe the file contents through strings and dos2unix before being able to use it.

Resources