<<< Date Index >>>     <<< Thread Index >>>

Re: Can one access the filename when using pipe command?



On 2005-07-01, Chris Green <chris@xxxxxxxxxxx> wrote:
> When using the pipe command to feed the contents of an attachment into
> a script/program is there any way to access the filename in the
> script?
> 
> I have a trivial script that allows me to save HTML messages directly
> into my public_html so I can view them with a browser (I connect to
> the system where mutt is remotely so firing up a browser directly,
> while possible, isn't exactly quick).
> 
> I'd like to do the same with attachments but they need to be saved
> with their filename intact so the browser recognises them as .PNG or
> .JPG files or whatever.
> 
> I can't just use 's'ave as firstly I'd need to navigate to the
> destination directory which is a hassle and secondly it saves with
> 0600 permissions and I need 0644 for the browser to be able to see the
> file. (Well the server actually, but you know what I mean)

As far as I know, there is no way to pass the file name to the pipe 
command.  However, the file name is available to the rules in your 
mailcap file.  So, you could add rules to your mailcap file 
something like this:

    application/*; save_this %s
    image/*; save_this %s

where save_this is a script that copies the argument file to your 
public_html directory.  To save the attachment to your public_html 
directory, select the attachment menu (type 'v' from the index or 
pager menu), move the cursor to the desired attachment, and hit 
Enter.

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA