Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to pipe the output file from the command line audio tool SoX into the email tool mutt.

What I want to do is something akin to this:

sox /Users/someUser/Desktop/input.mp3 output.mp3 | mutt -s "someSubject" -a [output-from-sox] some@recipient.com

The thing I don't know how to do is wrapped in square brackets.

I'm a UNIX novice so any hints would be highly appreciated.

share|improve this question
    
You don't mean sox /Users/someUser/Desktop/input.mp3 output.mp3 ; mutt -s "someSubject" -a output.mp3 some@recipient.com do you? You want to send the command line output? –  Daniel Beck May 17 '11 at 7:56
    
I want sox to output the mp3-file and mutt to email that file. I don't know if my pipe approach is the right way to do this :S –  timkl May 17 '11 at 8:08
    
Since your sox call writes output.mp3, why don't you just use that one like I suggested and delete it after sending? In case sending fails or something like that, you'll still have the file to try again. –  Daniel Beck May 17 '11 at 8:09
1  
Instead of using ; to separate the commands, use && so that the second command only runs if the first one was successful. –  Majenko May 17 '11 at 8:11
    
It's an Applescript that sends this line to the Terminal, so I would like to keep it in one line. –  timkl May 17 '11 at 8:13
show 3 more comments

1 Answer

up vote 1 down vote accepted

A pipe in a Unix-like operating system is for running one program, taking its standard output (which would otherwise go to the screen) and using it as input to another program (in place of its standard input which would normally come from the keyboard).

It seems like what you want to do is have one program output to a file, and then have another program use the file as input. You don't need a pipe for that.

To run one program after another one finishes, all on one command line, use ;. For example:

sox /Users/someUser/Desktop/input.mp3 output.mp3 ; mutt -s "someSubject" -a output.mp3 some@recipient.com

Unix command line programs output an "exit status" or "return code". Most programs output 0 to indicate that they did their thing successfully, or some other value if there was a problem. If your first command is like this, use && in place of ; to only run the second command if the first one was successful. For example:

sox /Users/someUser/Desktop/input.mp3 output.mp3 && mutt -s "someSubject" -a output.mp3 some@recipient.com
share|improve this answer
    
Really helpful explanation, thx a bunch! :) –  timkl May 17 '11 at 8:17
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.