problems with 'pipe' command

bonkers

Registered
I don't know what is happening, but in this specific case it seems to me that the 'pipe' command is the problem. I am trying to convert a postscript file into a pdf file (using ghostscript 7) and open it in preview.app using my "pdf" alias command.

[15:10][chris ~/plots]%ps2pdf ./test.ps ./test.pdf | pdf ./test.pdf
2001-10-21 15:12:00.613 open[823] No such file: /Users/chris/plots/test.pdf
[15:12][chris ~/plots]%ls
test.ps test.pdf

As you can see the file is definitely there! I know everything is working properly, because if I do this as two separate commands everything works fine. Any suggestions?

p.s. this wasn't a problem in 10.0.4
 
Sorry, this isn't a pipe problem. It's a user
error and lack of understanding about when and
why pipes get used.

ps2pdf doesn't send its output to STDOUT (try man ps2pdf) therefore, there is nothing to pipe. It creates
a new .pdf file and then exits. And I'll bet
preview doesn't accept STDIN either.

you want to two commands sequentally, not connect
them by pipe.
 
:mad: ouch! why don't you respond a little more harshly?

I used these same commands with 10.0.4 and they worked fine. It seems to almost work in 10.1, but it seems like preview.app is trying to open the file before it is fully converted to a pdf.

My question is how can I combine these two commands into one? If piping doesn't work then what will. I'm just trying to minimize the amount of typing I do for frequent commands.
 
Ok, here is how you do it...
Code:
$ ps2pdf ./test.ps ./test.pdf; pdf ./test.pdf

Also he responded harsly because this is a RTFM and PEBKAC error. You were using pipes in a way that they shouldn't have worked (in 10.0 this might have been a bug if it worked as you say it did, it should have been a bug if it did work). A pipe transports data from one command to another, so if you were going to try to pipe them you would probably want a command that looked somethign like:
Code:
$ ps2pdf ./test.ps - | pdf -
Assuming that ps2pdf supports using '-' as an indicator that it needs to write to stdout and that Preview supports reading from stdin and the '-' character as a flag that it needs to read from stdin. Those are prettyt tall assumptions unless you read the manual for either app.
 
Also he responded harsly because this is a RTFM and PEBKAC error.

Oh please.. I'm used to hearing the classic RTFM reponse from linux boards - the Mac OS X board has been far more user friendly so far, I hope we remain so. Anyone who says RTFM shouldn't take the time to respond, if they don't want to give a response. Mouthing off isn't going to help new mac users - and we want more mac users, right? Also, the manuals accessed through man or readme.txt on unix topics are normally so poorly written that only a seasoned user can guess at the meaning.
 
All I will say is thanks Jadey.:D

now back to my semi-problem...

so the new command I have is ...
$ | ps2pdf - ./test.pdf ; pdf ./test.pdf
where I am piping .ps output through ps2pdf to convert it, and then opening the pdf with preview.app. This works terrific if I type it all out. However, I would like to create an alias command to do this, but I have been unsuccessful.

Here is what I currently have in aliases.mine...
alias pspdf 'ps2pdf - \!* ; pdf \!*'
where "pspdf ./test.pdf" would come right after the 'pipe' command above. This doesn't work. Your help would be greatly appreciated.

Cheers
 
Originally posted by bonkers

so the new command I have is ...
$ | ps2pdf - ./test.pdf ; pdf ./test.pdf
where I am piping .ps output through ps2pdf to convert it, and then opening the pdf with preview.app. This works terrific if I type it all out. However, I would like to create an alias command to do this, but I have been unsuccessful.

I am assuming that there is a command that outputs a ps infront of that pipe right?


Here is what I currently have in aliases.mine...
alias pspdf 'ps2pdf - \!* ; pdf \!*'
where "pspdf ./test.pdf" would come right after the 'pipe' command above. This doesn't work. Your help would be greatly appreciated.

Cheers

What output do you get? Any error messages? It looks to me like you may want '\$*' instead of '\!*' but I use shell scripts instead of aliases usualy.
 
Sorry if I confused you. Yes, there IS a command that it puting .ps output into my pipe (it is command from a mapping program, but don't worry about that). The command and error message is below.

[8:21][chris ~/plots]%pstext -R0/7/0/7 -JX7i -P -B1g1 -G255/128/0 | pspdf test.pdf

2001-10-22 08:22:08.248 open[1265] No such file: /Users/chris/plots/test.pdf

Could it be a timing issue (i.e., preview.app is trying to open the file before it has been produced)?
 
Could be a timeing issue I guess. Why don't you use a shell script instead of an alias? Could be easier. Here is a short example of what I am thinking about:
Code:
#! /bin/sh

# This script will create a postscript file and convert it to a pdf before opening
# it in preview.

# Create a temp place for the ps file
TMP=`mktemp /tmp/pstextXXXX.ps`
# The name of the pdf output
PDFOUT="./test.pdf"

if [ -f $TMP ]; then
   # Run the command
   pstext -R0/7/0/7 -JX7i -P -B1g1 -G255/128/0 > $TMP
   ps2pdf $TMP $PDFOUT
   rm $TMP
   # Not sure of the CLI syntax of the open command off the top of my head
   open $PDFOUT
else
   echo "Can not open temp file! Can not continue!"
fi

This is just a very simple example of a shell script that would do this... you could make it much more elegant if you tried, with this you could also pass arguments to the pstext program easily.
 
im interested in how you got ghostscript 7 to install properly. im having a hell of a time creating the right make files and running the install script.

i just started about an hour ago though, so i may be able to figure it out soon
 
Back
Top