ShadowMage Posted October 8, 2009 Share Posted October 8, 2009 I have an automatic emailer that sends a pdf report every week. The report is generated using a php script. The report needs to be sent to only a specific group of users based on a particular condition. What I'm wondering is if it is possible to construct this recipient list in the php script, then pass that variable off to a bash script that emails the pdf file.Thank you Link to comment Share on other sites More sharing options...
AElliott Posted October 8, 2009 Share Posted October 8, 2009 Well... you could dump it in a temporary file (in bash format if you want) then read that into the bash script. If it's a short list you can pass them as parameters to the script call.I don't know of a way you could pass a variable more directly than that. I would probably dump a file in /tmp (on unix-like) and then loop over the contents of that file in bash myself. Link to comment Share on other sites More sharing options...
ShadowMage Posted October 8, 2009 Author Share Posted October 8, 2009 Could you give me a couple lines of code as an example? I don't really know much about bash. Link to comment Share on other sites More sharing options...
AElliott Posted October 8, 2009 Share Posted October 8, 2009 Heh, don't blame you, it's not exactly a particularly nice thing to work with. Here's a quick example of looping over the contents of a file called "tmp" (each entry is delimited by a newline): #!/bin/shCOUNT=0 # Initialise a count variable to show loopingfor DATA in `cat tmp` # here we're taking the contents of "tmp" to loopdo echo "$COUNT - $DATA"; # Just output the data, you'd do something different COUNT=$(($COUNT+1)); # Increment countdone So, for a file containing "foo\nbar\nbork" it outputs: 0 - foo1 - bar2 - borkYou'd of course have a different loop body, but it's an example of the main idea. Link to comment Share on other sites More sharing options...
ShadowMage Posted October 8, 2009 Author Share Posted October 8, 2009 OK so next question. I'm already dumping the pdf generated by php into a file, can I still dump the recipient list to a different file? If so how do I do that? Link to comment Share on other sites More sharing options...
AElliott Posted October 8, 2009 Share Posted October 8, 2009 Of course you can, get your list, and use the filesystem functions like file_put_contents() or fwrite() to write what data you want where you want. Link to comment Share on other sites More sharing options...
ShadowMage Posted October 8, 2009 Author Share Posted October 8, 2009 Doh! Of course! :)Thank you so much for your help! I really appreciate it! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.