Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Alternative Computing > Linux Support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Linux Support Linux - Operating Systems and Applications Support

Reply
 
LinkBack Thread Tools
Old 11-03-2009, 01:09 PM   #1 (permalink)
Registered User
 
Join Date: Oct 2009
Location: Sayre, Williamsport, Philadelphia
Posts: 13
OS: Win XP sp2, Vista Business, Ubuntu, Server 2k3, Server 2k, Kazeon


Pin piping

I am using the BASH command 'find' for to list each file in the directory and sub directories. I would like to send each of these files to formail to be converted to .mbox. However, My output is only all the file paths instead of a seperate converted file for each. Here is the BASH line I am using.

find | cat | while read line; do /usr/bin/formail > mail/FindMbox/$file.mbox; done

It creats a file name 20.mbox (i assume my $file syntax is incorrect) which contains only the output of the find command.

Any idea on how I can get /usr/bin/formail to look at each line and convert the seperate files?
Andy(m) is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 11-05-2009, 08:33 AM   #2 (permalink)
JKR
Registered User
 
Join Date: Jan 2007
Location: Wuhan, China
Posts: 53
OS: XP, Ubuntu


Re: piping

You could use awk.
JKR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-06-2009, 09:48 AM   #3 (permalink)
Registered User
 
Join Date: Oct 2009
Location: Sayre, Williamsport, Philadelphia
Posts: 13
OS: Win XP sp2, Vista Business, Ubuntu, Server 2k3, Server 2k, Kazeon


Re: piping

I tried using awk... but it didn't really make a difference. I wrote a script to do an ls -1 on each folder and then pipe the lines to formail. But, that still doesnt work. It just gives me a single file output and doesnt actually convert the data.

When i run formail for just one messages, i still cant extract the data. So, it doesnt really make a difference if i can loop them or not.
Andy(m) is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-06-2009, 07:54 PM   #4 (permalink)
JKR
Registered User
 
Join Date: Jan 2007
Location: Wuhan, China
Posts: 53
OS: XP, Ubuntu


Re: piping

Sorry, I don't have formail installed on my system, so I can't try it myself. However, I'd try to cut down the problem in pieces to find out where the problem is.

To do this, I'd first redirect the output of the find command into a file list, like
ls -1R | grep -iv "./" >filelist.file (note that it is ls minus one big R, not minus small L)

Look at the created file to see if the output really is what you'd like to pipe ontu your formail command.

In a second step, let's see if the formail command works on your input.
head 1 filelist.file | formail

In a third step, do something like
for i in {1..`wc -l filelist.file`}
do
head $i filelist.file
done

and in a last step
for i in {1..`wc -l filelist.file`}
do
head $i filelist.file | formail
done

This way you'll find out which step in your command pipe is broken, and you can correct it step by step.

Note that "do something like" means that my syntax is incorrect.

From your first post I guess that your "find" is shorthand for something much longer like find my_directory -n mynames* -exec .... The output of your find command will be a list of files. You pipe it onto a cat. cat will show you the content of one file (as opposed to a list of files). There might be more than one problem in your command chain, so I think it's best to tackle them step by step.

Good luck!
JKR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-09-2009, 08:10 AM   #5 (permalink)
Registered User
 
Join Date: Oct 2009
Location: Sayre, Williamsport, Philadelphia
Posts: 13
OS: Win XP sp2, Vista Business, Ubuntu, Server 2k3, Server 2k, Kazeon


thanks, I will try this now.

wrote a different script that works, but is similar to your advice.. thanks!

Last edited by wmorri; 11-10-2009 at 07:35 PM. Reason: merge
Andy(m) is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-10-2009, 05:35 PM   #6 (permalink)
JKR
Registered User
 
Join Date: Jan 2007
Location: Wuhan, China
Posts: 53
OS: XP, Ubuntu


Re: piping

I'm glad that it worked for you. Have a look at the -exec part of man find, too, it could be useful in this kind of situations.
JKR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 06:01 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85