Q:

Stata and Named Pipes

Instead of decompressing via a temporary file,  I can use named pipes to read .csv.gz and .dta.gz files directly in Stata as explained here. I have two questions about how to use named pipes in Stata in case someone is knowledgeable about them.

The help advises to do the following (edit: which indeed works for me)
 #!/bin/sh
 fname=$1
 rm -f mypipe.pip
 mknod mypipe.pip p
 zcat $fname > mypipe.pip &
 !myprog testfile.Z >& /dev/null < /dev/null
 infile a b c using mypipe.pip

I'd like to understand why the following code does not work.
 !rm -f mypipe.pip && mknod mypipe.pip p && zcat filename.gz > mypipe.pip &
 infile a b c using mypipe.pip

Is there is a similar way to use named pipes when saving and gzipping .dta files? I have tried to replicate the code above but without success.

A:

Edit:
It's because you haven't recreated the code as called in the bash file + the stata do file. You've just done the bash file.
Your code should read:
!rm -f mypipe.pip && mknod mypipe.pip p && (zcat filename.gz > mypipe.pip &) >& /dev/null < /dev/null
infile a b c using mypipe.pip

If you could post what errors you're getting as per Nick's suggestion about clearing up what "does not work" means that would be helpful.
In any case there are a few things you should try first
(1) Create a bash script as per your link to the Stata website instead of trying to do it on one line
(2) Make sure your filename has no spaces, or put double quotes around $fname
(3) Make sure to chmod 775 /path/to/myprog to make it executable if you run *nix
(4) Make a do file as per your link again
(5) Put a pound sign after testfile.Z like the following : !myprog testfile.Z #>& /dev/null < /dev/null infile a b c using mypipe.pip this allows output to go to standard output so you can see whats going on. you can remove this after the problem is diagnosed.
(6) Change the !myprog to !/path/to/myprog
(7) Execute do mytest.do
(8) Tell us what Stata is saying the error is if any remain.
It works on my machine with .csv files so long as you specify all the variable names after infile, haven't got it to work with dta files. Here is the procedure
First make a bash file called myprog as recommended 
#!/bin/sh
    cd /path/to/dir
    fname=$1
    rm -r mypipe.pip
    mknod mypipe.pip p
    zcat $fname > /path/to/dir/mypipe.pip &

make the script executable by typing in a terminal:
`chmod 775 /path/to/dir/myprog'
Then make a do file. I have a dataset called complete which I used to test the principal
cd /path/to/dir

insheet using complete.csv
ds *
global vars "`r(varlist)'"

!7z a test.csv.gz complete.csv

!/path/to/dir/myprog test.csv.gz >& /dev/null < /dev/null
infile $vars using mypipe.pip, clear

Success. I'm running Debian Linux Wheezy (actually #! but same deal), using Stata version 12

