LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-08-2011, 04:55 AM   #16
swapna sree
LQ Newbie
 
Registered: Jul 2011
Location: Hyderabad
Posts: 20

Original Poster
Rep: Reputation: 0
Smile


Hi colucix

you are helping me alot ..thanks

If i use backslash ..Even now its asking for the input and the same problem is continuing..like CTRL+C must enter to exit from execution of process..

Last edited by swapna sree; 07-08-2011 at 04:57 AM.
 
Old 07-08-2011, 09:16 AM   #17
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Please post the relevant part of your script as it is now. In the meanwhile I've tested the C-shell and the following script works for me:
Code:
#!/bin/tcsh
set FILENAME=testfile

#
#  Do TXT to HTML conversion (uses AWK)
#
awk ' \
  BEGIN { print "<html>" \
          print "<head>" \
          print "</head>" \
          print "<body bgcolor=\"#ffffff\" text=\"#000000\">" \
          print "<pre>" \
  } \
\
  {  \
    gsub(/Fund name/,"<b>Fund name</b>") \
    gsub(/1234/,"<b>1234</b>") \
    print $0 \
  } \
\
  END { print "</pre>" \
        print "</body>" \
        print "</html>" \
  } \
\
' $FILENAME > $FILENAME.html

#
#  Send mail (uses SENDMAIL)
#
/usr/sbin/sendmail -f "my.address@my.domain" "my.address@my.domain" << EOF
From: Me <me@somewhere>
To: You <you@somewhere>
Cc: Someone Else <someone@somewhere>
Subject: Message Title
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline

<pre>Any text here</pre>

`cat $FILENAME.html`
EOF
It doesn't expect anything from standard input (as it should be). A question: are you using /bin/csh or /bin/tcsh?
 
Old 07-12-2011, 12:43 AM   #18
swapna sree
LQ Newbie
 
Registered: Jul 2011
Location: Hyderabad
Posts: 20

Original Poster
Rep: Reputation: 0
Hi colucix,

Even though i use #!/bin/tcsh or #!/bin/csh

Its giving an error like

awk: syntax error near line 2
awk: bailing out near line 2


the code which is written in awk is not executing..
 
Old 07-12-2011, 12:47 AM   #19
swapna sree
LQ Newbie
 
Registered: Jul 2011
Location: Hyderabad
Posts: 20

Original Poster
Rep: Reputation: 0
Hi coulix,
My script is


Code:
#!/bin/tcsh -f
source $ROOT/scripts/SetEnv
setenv DSQUERY $REPORT_DSQUERY
setenv DBUSER $REPORT_DBUSER
setenv DBPASSWD $REPORT_DBPASSWD
setenv DBNAME $REPORT_DBNAME
setenv SENDFROM $RPT_EMAIL_SENDFROM

setenv SENDTO "myemailid@some.com"
setenv FILENAME $ROOT/scripts/swapna.txt
echo "CALLING THE PROCEDURE"
setenv DBSQL "exec CFA_CommitmentNAVCalc "
$ROOT/scripts/sybaseOutput.pl

#set FILENAME=testfile

#
#  Do TXT to HTML conversion (uses AWK)
#
awk ' \
  BEGIN { print "<html>" \
          print "<head>" \
          print "</head>" \
          print "<body bgcolor=\"#ffffff\" text=\"#000000\">" \
          print "<pre>" \
  } \
\
  {  \
    gsub(/Fund name/,"<b>Fund name</b>") \
    gsub(/1234/,"<b>1234</b>") \
    print $0 \
  } \
\
  END { print "</pre>" \
        print "</body>" \
        print "</html>" \
  } \
\
' $FILENAME > $FILENAME.html

mail -s "Message Title " $SENDTO  <<EOF
`cat $FILENAME.html`
EOF

echo "==========done-======="
exit 0
when we execute the above shell script the data is as follows:

Starting copy...

2 rows copied.
Clock Time (ms.): total = 1 Avg = 0 (2000.00 rows per sec.)
CALLING THE PROCEDURE
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
swapna.txt: 1 rows selected
awk: syntax error near line 2
awk: bailing out near line 2

Last edited by colucix; 07-12-2011 at 01:10 AM.
 
Old 07-12-2011, 01:15 AM   #20
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by swapna sree View Post
awk: syntax error near line 2
awk: bailing out near line 2
The "bailing out" error let me suspect you're not running GNU awk. Is this a Solaris machine? I cannot test it right now, but if you have nawk available (or even better the gawk command) try to substitute awk with that.
 
Old 07-12-2011, 01:29 AM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I can't seem to think of any OS that would use tcsh by default ... :}
 
Old 07-12-2011, 02:06 AM   #22
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by Tinkster View Post
I can't seem to think of any OS that would use tcsh by default ... :}
I remember when I worked on Silicon Graphics or Sun SPARC workstations, they had tcsh as default shell, /bin/sh for crontab and no bash available. Indeed on Unix systems you have to install GNU tools, that is you don't have them available if the system administrator doesn't provide them to the users.
 
Old 07-12-2011, 05:22 AM   #23
swapna sree
LQ Newbie
 
Registered: Jul 2011
Location: Hyderabad
Posts: 20

Original Poster
Rep: Reputation: 0
Hi coulix,

If i use gawk instead of awk its working without any error
But the problem is ,
the code which we wrote in gawk like HTML code is not affecting the data
its displaying as a plain text itself

No bolded or no fontcolor etc......
 
Old 07-12-2011, 08:44 AM   #24
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by swapna sree View Post
the code which we wrote in gawk like HTML code is not affecting the data
its displaying as a plain text itself

No bolded or no fontcolor etc......
I'm lost now. Indeed an HTML file is a plain text file. It is the software that manages the file that can interpret the formatting strings. In this case you told that the text should be sent by e-mail, then if the mail client uses HTML to send the message, the receiver should see the color/bold formatted output (if it uses HTML as well). Or am I missing something?
 
Old 07-12-2011, 10:29 AM   #25
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
I'm sorry but as I can see (I'm not sure) is that your code makes "<pre>" tag coding for the text you are searching,
which in HTML doesn't make any sense of formatting, since <PRE> means no formatting ?!

Try formatting the HTML text file properly:
Code:
instead
          print "<head>" \

replace with:
<head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
Maybe substitute the body default font:
Code:
print "<body bgcolor=\"#ffffff\" text=\"#000000\">" \
with
print "<body bgcolor=\"#ffffff\" text=\"#000000\" style=\"font-family:\"Courier New\" , Courier , monospace ;\">" \
and also replacing the "<b>" with "<strong>"

would make difference (as send_html_email_from_command_line and bash-send-html-email-from-linux-command-line suggests)

Last edited by lithos; 07-12-2011 at 10:32 AM.
 
Old 07-12-2011, 12:19 PM   #26
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
http://www.linuxquestions.org/questi...cedure-890181/


*sigh*


Not a very perceptive OP, it appears.



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
print text color using perl john83reuben Programming 4 12-04-2009 01:11 AM
How change text color using linux in text mode only runlevel 3? Xavius Linux - General 7 05-07-2009 03:19 AM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 03:36 PM
how to print text in color by ncurses without opening a ncurses window Greatrebel Programming 0 12-20-2006 10:15 AM
Konqueror (webbrowser part) only displays text in BOLD jeroenvrp Linux - Software 0 07-24-2004 10:35 AM


All times are GMT -5. The time now is 06:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration