How do I stop printf output from going into seperate txt files

I am using

printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y > status

It works really well, however, when I email status it is sending 10 emails when I would like it to be in one.

Is there a way to make all the output to go into one instance of a txt file. Yet still keep it 1 on each line?

Chris

I think we need to see more of your script.
What do you mean by 10 emails? Ten separate emails sent to one person? Ten files?

What I mean is whats supposed to happen is all of the output should go to one text file status. Whats happening is printf is copying one line at a time and creating a new status txt file every time.
Here is the almost completed script.


echo What is the account name?
read account
echo What is the email?
read email
echo How many hours?
read  hours
let t=$hours*60

find . ! -name '.*'  -type f -mmin "+$t" > holder
cut -c 3-70 holder > uploads
for f in $(<uploads); do s=`echo "$PWD/$f" | sed -e "s/^.*\.fileburst\.com/$account.fileburst.com/"`;z=`ls -la "$f" | awk '{ printf("%10d\n", $5)}'`; x=`ls -la "$f"| awk '{printf("%3s-%2s-%4s", $6, $7, $8)}'`;y=`md5sum "$f"| awk '{print $1}'`;
#echo -e "$s\t\t$z\t$x\t$y"
printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y > status

##mail -s "The following files have been uploaded to your directory chris2" -c "chris.collins@fuse.net" susant <  status
rm -rf uploads
rm -rf holder
done

When it emails status, it is also 1 email 1 line at a time.

Chris

Try this one (I didn't test it, so it may be considered as pseudocode, just idea)

echo What is the account name?
read account
echo What is the email?
read email
echo How many hours?
read  hours
let t=$hours*60

find . ! -name '.*'  -type f -mmin "+$t" > holder
cut -c 3-70 holder > uploads
echo > status
for f in $(<uploads); do s=`echo "$PWD/$f" | sed -e "s/^.*\.fileburst\.com/$account.fileburst.com/"`;z=`ls -la "$f" | awk '{ printf("%10d\n", $5)}'`; x=`ls -la "$f"| awk '{printf("%3s-%2s-%4s", $6, $7, $8)}'`;y=`md5sum "$f"| awk '{print $1}'`;
#echo -e "$s\t\t$z\t$x\t$y"
printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y >> status

done

mail -s "The following files have been uploaded to your directory chris2" -c "chris.collins@fuse.net" susant <  status
rm -rf uploads
rm -rf holder
rm -rf status

You are an absolute life saver! Thank you

Here is the code

[CODE]
printf "%-75s%+10s %5s %1s \n" $s $z $x $y >> status

mail -s "Uploads!" -c "chris.collins@fuse.net" susant < status

Here are the two issues-

1) the format that printf allowed me to have where my output was in columns is messed up when I mail it to an email address. It no longer lines up in columns.

2) The other issue is I am recieving multiple emails with this mail commad, instead of just 1??? I am not sure if this is a printf issue or a mail issue?

Chris

  1. Can you copy and paste the output of a mail received into a post so that users can see in what way the output is malformed. (Edit as required to remove personal information, but try to keep the same number of characters)

  2. You will need to include more of your script. There does not appear to be anything in what you have posted thus far to cause the problem.

I hope this posts correctly

chris.domain.com/web_users/chris2/red                                            5   Jul-25-03:06   99e4e22dda38bc735e56341dedcf4ba5  
chris.domain.com/web_users/chris2/best                                         311   Jul-18-17:17   35c1b42c2540e869fc55fafab0140895  
chris.domain.com/web_users/chris2/new/yellow                                     7   Jul-25-03:07   51b19ed7e4dcad54b0a16d6cd3d4b92f  
chris.domain.com/web_users/chris2/new/new                                        7   Jul-25-03:06   3af0030870e2e4ec46cb625215323728  
chris.domain.com/web_users/chris2/new/hello                                      5   Jul-25-03:10   a91520833605d8d629b47f8ac6a8a13e  
chris.domain.com/web_users/chris2/wantstochat_long.wav                       85306   Jul-25-00:20   ab7a1ff08327366c8026c231ce69a8d4  
chris.domain.com/web_users/chris2/urlruby.txt                                  188   Jul-25-00:20   939d9705b71a06f0c863501f97ca7344  
chris.domain.com/web_users/chris2/im444333444.txt                            34353   Jul-25-00:21   a84ff6f68d9d7842d1eb15708c5b69a6  
chris.domain.com/web_users/chris2/im444.txt                                  12709   Jul-25-00:21   b8800324670b6052148f6c72673b6862  
chris.domain.com/web_users/chris2/test                                         207   Jul-20-20:50   f94739cbec5315f24b739cd5924e6610  
chris.domain.com/web_users/chris2/rest                                           339   Jul-20-17:04   8dff310f9fdce8ec636857e589240487  
chris.domain.com/web_users/chris2/sea                                            510   Jul-25-03:15   9259b0e3e1102c1f6bcce0e0715f740f  
chris.domain.com/web_users/chris2/me                                             177   Jul-25-00:58   d97ad3f9138b6a8fa1e1e401f2571851  
chris.domain.com/web_users/chris2/lake                                           468   Jul-25-01:47   9261182605cd9549f6a88697dc40abca  
chris.domain.com/web_users/chris2/red                                              5   Jul-25-03:06   99e4e22dda38bc735e56341dedcf4ba5  
chris.domain.com/web_users/chris2/best                                           311   Jul-18-17:17   35c1b42c2540e869fc55fafab0140895  
chris.domain.com/web_users/chris2/new/yellow                                       7   Jul-25-03:07   51b19ed7e4dcad54b0a16d6cd3d4b92f  
chris.domain.com/web_users/chris2/new/new                                          7   Jul-25-03:06   3af0030870e2e4ec46cb625215323728  
chris.domain.com/web_users/chris2/new/hello                                        5   Jul-25-03:10   a91520833605d8d629b47f8ac6a8a13e  
chris.domain.com/web_users/chris2/wantstochat_long.wav                         85306   Jul-25-00:20   ab7a1ff08327366c8026c231ce69a8d4  
chris.domain.com/web_users/chris2/urlruby.txt                                    188   Jul-25-00:20   939d9705b71a06f0c863501f97ca7344  
chris.domain.com/web_users/chris2/im444333444.txt                              34353   Jul-25-00:21   a84ff6f68d9d7842d1eb15708c5b69a6  
chris.domain.com/web_users/chris2/im444.txt                                    12709   Jul-25-00:21   b8800324670b6052148f6c72673b6862
  

Ok that didn't work, does anyone have any suggestions about the best way to post this?

Do i need to quote each line?

I've edited you post to uses code tags, that's the easiest way.

Try removing the spaces in your printf statement.

printf "%-75s%+10s%5s%1s\n" $s $z $x $y >> status

I found out the mail format was exactly the way I wanted it. My email client was not showing true text. So I had to set it to show the original format. I can't believe I spent 3 days debugging a script and it didn't need it, or at least that part.

Thanks for all your help

Chris

I actually do have one last question, is there a way to specify a different email address than the user thats logged in in this command. A From Field?

mail -s "Uploads!" -c "$email" susant <  status

If not what would be the equivilant sendmail command?

thank you
chris

Yes, just put a line with:

From: <sender>

at the start of the status file, and it should override the username. If you are unsure of the exact format it should have, just veiw the header of an email you have received and look for that line, and copy its format.