473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

New Line is not printing for certain messages

AIX
I have a set of commands that run and if a difference is found it prints a message to an array and then sends that array in an email. certain messages are not printing the new line after the text. others are.

code:

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\n";
  2. push @messages, $message;
at the end i will prepare to send in an email.
Expand|Select|Wrap|Line Numbers
  1. $message = join('',@messages);
  2. $subject = "XXXXXX";
  3. &mail_admin($subject,$message);
output =
A difference in /opt/local/bin has been noted: clean_oratab is no longer available A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

These lines print right next to each other with out a new line.

if i join with a '\n' then it will print a seperate line, but alos a blank liner between them:
Expand|Select|Wrap|Line Numbers
  1. $message = join('\n',@messages);
output =
A difference in /opt/local/bin has been noted: clean_oratab is no longer available

A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

I do not want the whitespace between them.

if i take the program through debug, all the way to the end an view @messages or $message everything is spaced correctly.

if i add '' between the command and the end of the message it will print correctly, but leaves the ''.

code:

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: '$opt_local_bin{$file}{'new'}{'file'} is now available'\n";
  2. push @messages, $message;
output =
A difference in /opt/local/bin has been noted: 'clean_oratab is no longer available'
A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available


Any ideas before i give up?
Mar 31 '08 #1
3 1343
SpecialKay
109 100+
did you try the join with the new line char, and take the new line char off the end of the string...
unless i miss understood your problem, that should work
Mar 31 '08 #2
SpecialKay
109 100+
or:
might need to put single quotes around the \n inside your string.

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available '\n' ";
  2.  
  3. and if memore serves right you need to put quotes around the single quote.  But that might be in a differant language, or im crazy.  Try it out for the syntax.
  4.  
AIX
I have a set of commands that run and if a difference is found it prints a message to an array and then sends that array in an email. certain messages are not printing the new line after the text. others are.

code:

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\n";
  2. push @messages, $message;
at the end i will prepare to send in an email.
Expand|Select|Wrap|Line Numbers
  1. $message = join('',@messages);
  2. $subject = "XXXXXX";
  3. &mail_admin($subject,$message);
output =
A difference in /opt/local/bin has been noted: clean_oratab is no longer available A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

These lines print right next to each other with out a new line.

if i join with a '\n' then it will print a seperate line, but alos a blank liner between them:
Expand|Select|Wrap|Line Numbers
  1. $message = join('\n',@messages);
output =
A difference in /opt/local/bin has been noted: clean_oratab is no longer available

A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

I do not want the whitespace between them.

if i take the program through debug, all the way to the end an view @messages or $message everything is spaced correctly.

if i add '' between the command and the end of the message it will print correctly, but leaves the ''.

code:

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: '$opt_local_bin{$file}{'new'}{'file'} is now available'\n";
  2. push @messages, $message;
output =
A difference in /opt/local/bin has been noted: 'clean_oratab is no longer available'
A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available


Any ideas before i give up?
Mar 31 '08 #3
KevinADC
4,059 Expert 2GB
Instead of this unecessary stuff:

Expand|Select|Wrap|Line Numbers
  1. $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\n";
  2. push @messages, $message;
  3.  
  4. $message = join('',@messages);
  5. $subject = "XXXXXX";
  6. &mail_admin($subject,$message);
try like this, concatenate using '.=' in the loop you use to create the message and use \r\n instead of \n:

Expand|Select|Wrap|Line Numbers
  1. $message .= "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\r\n";

then run it as you are:

Expand|Select|Wrap|Line Numbers
  1. $subject = "XXXXXX";
  2. &mail_admin($subject,$message);
Mar 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Toro | last post by:
Hi, I want to control the output such that it always print at the same line, erasing the line just printed (or erasing a particular posistion at a certain line). Say, for a simple program like...
3
by: Charles L | last post by:
Can someone provide me of an example of the use of the #line preprocessor directive? I am not 100% sure how you use it. Charles L
2
by: jim_geissman | last post by:
I have a script or SP that takes a very long time to perform multiple tasks, and after each one there is a PRINT statement that shows the time and what was just accomplished, to help me monitor...
5
by: zeljko.markic | last post by:
I want to implement silent printing in my project to print reports programmatically, so that a user will not see any pop-up messages to do with the printing process. For instance, I want to hide...
4
by: Russ | last post by:
To ASP.NET printing experts: My Asp.net web form needs to print some reports at the client side. I've been trying to research this and find some confusing and conflicting information in previous...
1
by: Raymond Du | last post by:
Hi, I have serveral web forms used by users, these users often use IE browser print function to print out the form, the problems I have is what users see on the screen is usually different from...
1
by: Rhino | last post by:
I have a working knowledge of CSS but I've been away from it for a while so I'd really appreciate it if someone could get me started with a problem I'm having. I have a wiki which displays just...
0
by: M. Bruil | last post by:
I've created a project which runs as Windows service (Visual Studio 2005). Part of this project is printing (Crystal reports) and sending email messages with file attachments. The service is...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.