I have a large text file containing many sqlite3 commands. I am executing the file with:
set databasePath to quoted form of "/path/to/sqlite/database"
set textFile to quoted form of "/path/to/sqlite/commands"
do shell script ("sqlite3 " & databasePath & " < " & textFile)
Only half of the commands seem to execute. When I issue the same command in Terminal, everything works as expected. It seems that do shell script is terminating before the sqlite3 commands have completed. Any ideas? Would redirecting help?
I haven’t seen your script, but my guess is is that your sequence of commands somehow resets something and terminates the script before it is completed.
First of all, you should take the whole content of your do shell script, and paste it into TextWrangler, and look for invisible characters.
In the do shell script you’d really have to move an echo statement or similiar downwards, between runs, until you find the place it breaks, and take it from there. Maybe it could help, if you took the whole do shell script command, with/without double quotes and piped it to stdout, in a terminal window, into “od -cb”, or “sed l” or “cat -vt”, or “xxd” (man xxd) for that matter to reveal any peculiar character, or sequence of escaping strings, or help you see what parts of the script are escaped/not. You could of course also echo your whole do shell script command sequence in a do shell script, and see what you get back!
I hope this somehow have given you some ideas, or may help you get ideas to solve your problem.
Edit
If you have other things than sqlite commands in your script, then it may very well be that there is a deviation between paths in terminal, and what do shell script handles. That you address something by a path specified in .bash.rc or .profile, then the do shell script command would get to be prematurely terminated.