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