Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Display Pie Chart/Bar Graph in microsoft outlook email using UNIX commands/Shell scripts Post 302938410 by Don Cragun on Monday 16th of March 2015 02:39:05 AM
Old 03-16-2015
Quote:
Originally Posted by bikerboy
I have a shell script which executes to write html codes into a text file. My next step is to email the text file so that receiving person (people who i send email to) should be able to see pie/chart or bar graph (whatever i design in my code) in their email. Following is the example of a sample shell script which writes a html file with pie chart codes in it. I need to email this html file and the receiver needs to see the pie chart in their email.

Code:
#! /bin/bash

TEMP=$(mktemp -t chart.XXXXX)
QUERY1=33
QUERY2=67
cat > $TEMP <<EOF
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

google.load('visualization', '1.0', {'packages':['corechart']});

google.setOnLoadCallback(drawChart);

function drawChart()
{

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Title');
        data.addColumn('number', 'Value');
        data.addRows([
                        ['Error Percentage', $QUERY1],
                        ['No Error Percentage', $QUERY2]
                    ]);

        var options = {'title':'Errors',
                        'width':400,
                        'height':300};

        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
}
</script>
</head>

<body>
<div id="chart_div"></div>
</body>
</html>
EOF


I have tried using mutt and send email but nothing works.

I have tried :
Code:
mutt -e 'set content_type="text/html"' someone@gmail.com -s "test_piechart" < chart.XXXXX

chart.XXXXX is the filename created when the shell script is executed and this chart.XXXXX file will have the html content in it.

Appreciate your time and help.

Thanks!!
Moderator's Comments:
Mod Comment Please use CODE tags for ALL sample input, output, and code segments.
No. The command TEMP=$(mktemp -t chart.XXXXX) (and your shell script above) does not create a file named chart.XXXXX, it creates a file with a name more like:
/var/folders/hb/zmv2wvjx07sc_lqgzmwrsvt80000gn/T/chart.XXXXX.32sQA0j4 (your pathname will vary, but this is the pathname of the file created when I ran that command on my system a few minutes ago).

So, the command:
Code:
mutt -e 'set content_type="text/html"' someone@gmail.com -s "test_piechart" < chart.XXXXX

will probably generate an error message saying something like:
Code:
bash: chart.XXXXX: No such file or directory

unless you created a file by that name some other way.

If you use mktemp to create your output file, your script needs to also produce output that will allow other programs that want to use that data to find the output file it created.

What operating system are you using? On most systems, the options to mutt should be presented before the operands. Did you get any output at all from the commands you ran?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix to MicroSoft Outlook Mails

I want to send a text file from Unix as an attachment to a Microsoft Outlook address. I have tried the 'elm' command which does this. But it is in an interactive mode. I want this to be automatically done by a program. Is there any other way to this? (3 Replies)
Discussion started by: Deepali Potnis
3 Replies

2. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

3. UNIX for Dummies Questions & Answers

?Using Unix commands in Microsoft (Windows') DOS Prompt?

I ran a search for "Unix Dos" in the search field box and checked a few pages' results but did not find what I was looking for. I am trying to find out if there are choices of applications that would enable using Unix commands inside a Windows environment, particularly the DOS Prompt. The only... (2 Replies)
Discussion started by: HLee1981
2 Replies

4. UNIX for Dummies Questions & Answers

Is it possible to install microsoft outlook on unix

Hi Every one, I have to install microsoft outlook on unix operating system. We can install microsoft outlook on Linux operating system using WINE HQ Emulator. Like wise any Emulator , interface or compatibility layer for running Windows Applications. Please give some suggestions links to do... (3 Replies)
Discussion started by: carthikn
3 Replies

5. Shell Programming and Scripting

Automatic generate 3D pie Graph

Hello all, I need the scripts automatic generate 3D pie Graph. What I have now is as below: Run at terminal by $ CMD R BATCH graph.R # 3D Exploded Pie Chart library(plotrix) slices <- c(20, 15, 4, 15, 8) lbls <- c("Media", "Document", "DB", "Others", "Available") pct <-... (5 Replies)
Discussion started by: sheikh76
5 Replies

6. Shell Programming and Scripting

Send SAS Graph in Email Body from UNIX

Hi Friends, I am trying to send a graph in Body of HTML Email which is generated using a SAS Code. But, I am not able to see the picture, Instead seeing a red cross mark in Email Body. Could you please help me in fixing this problem? Also, I do not have a Shared Place (or) a web server to... (0 Replies)
Discussion started by: Samuels
0 Replies

7. Programming

Draw Bar Graph for GNUPLOT

For example, I have a file called data.txt. And the content is: Iker_Casillas 181 Raphael_Varane 182 Sergio_Ramos 182May I know how to write a script for gnuplot, so I can have a bar graph as the column 1 will be the x and column 2 will be the y? And I hope that the x value can be seen clearly.... (0 Replies)
Discussion started by: Tzeronone
0 Replies

8. Shell Programming and Scripting

Generate draft email in Outlook with shell script.

Hi All, Is there any way to create a draft mail with HTML body in Outlook using Shell script. (2 Replies)
Discussion started by: Girish19
2 Replies

9. Shell Programming and Scripting

UNIX script email to outlook report format

I have a ksh script that emails a report to outlook from a Unix Solaris. On server the report formatted perfectly. However, the email version the format is not. On the server report looks like this: TN Region Old SPiAD Server Order/Req Local Status NAAC Status Request Date New... (1 Reply)
Discussion started by: mrn6430
1 Replies

10. UNIX for Beginners Questions & Answers

UNIX commands and scripts

Hi guys, Hoping someone can help with the below - involves basic commands and some scripting. Thanks so much in advance for your amazing time and help. 3. The file /etc/profile contains the default initialization options for your shell. Produce a unique list of all variables with uppercase... (1 Reply)
Discussion started by: edujs7
1 Replies
All times are GMT -4. The time now is 08:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy