Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm been playing around with SQlite at work, specifically with trying to get the sqlite3 command line tool to accept stdin instead of a file. Sounds easy enough, on linux you can execute a command like:

echo 'test' | sqlite3 test.db '.import /dev/stdin test'

unfortunately - our machines at work run AIX (5 & 6) and as far as I can tell, there is no equivalent to the virtual file /dev/stdin. I managed to hack together an equivalent command that works on AIX using a temporary file.

echo 'test' | cat - > /tmp/blah ; sqlite3 test.db '.import /tmp/blah test' ; rm /tmp/blah

Now, does it need to use STDIN? isn't this temporary file thing enough? Probably, but I was hoping someone with better unix-fu had a more elegant solution.

note: the data I would like to import is only provided via STDOUT, so that's what the echo 'test' command is all about.

Clarification - I only have control over commands on the Right Hand Side of the pipe shown above. The data is being processed, and then passed to my command via stdin/stdout. the echo 'test' command is illustrative only.

share|improve this question
I'm assuming there's a typo in your second command. Where it says "/dev/stdin" should it say "/tmp/blah"? – Dennis Williamson Jun 9 '10 at 11:23
hahhah - yeah it totally should, i reread that a bunch of times. – mikfreedman Jun 9 '10 at 13:16
Does AIX have /dev/fd/? If so, then /dev/fd/0 should be the same as /dev/stdin. – larsks Nov 18 '10 at 2:47

If you're actually using Bash and AIX supports process substitution (which I believe is platform dependent), this might work for you:


cat <(echo 'test')

Your command:

sqlite3 test.db '.import '<(echo test)' test'
share|improve this answer
the echo test bit unfortunately isn't another unix command line tool - it's some random program that communicates via stdin/stdout, but has a convoluted execution framework that wouldn't allow it to be called that way, if that makes sense. – mikfreedman Jun 9 '10 at 13:18
@mikfreedman: I don't understand. If it can be called in a pipeline, it can be called using process substitution. Also, in your second command in your question why use cat -? Why not echo 'test' > /tmp/blah? – Dennis Williamson Jun 9 '10 at 13:43
in the program I am using, I can enter a unix command that the program will write to, the only requirement is this program can only write to STDOUT.. so, it's arriving at my arbitrary command via a pipe, but the order must be as I described. For reference the program I am using is Infosphere DataStage. – mikfreedman Jun 9 '10 at 14:08

Based on the answers above:

... | sqlite3 test.db 'import '<(cat -)' test'

I've tested this on my system and it appears to do what you want.

share|improve this answer

If the STDIN hacks aren't working on that platform, how about using a named pipe instead of the temp file? It'd behave from the perspective of the two programs like a file, but without the actual writing to and reading from disk.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.