Operating System - HP-UX
1745871 Members
4305 Online
108723 Solutions
New Discussion юеВ

ux2dos file from unix to dos

 
SOLVED
Go to solution
DeafFrog
Valued Contributor

ux2dos file from unix to dos

I am trying to send last line of log file (say syslog.log) in mail as ,

sendmail -f monitoring@server21.com -t rtango@server21.com<<EOF
Subject:ALERT:SERVER - AnyNAme : OS USER - AnyUSER EXPIRES IN anydays left DAYS
`tail -20 /var/adm/syslog/syslog.log >> /tmp/test123.txt;cat /tmp/test123.txt`
EOF

1)when i open it in unix it like this :

Mar  6 07:00:00 server21 ntpdate[8270]: step time server 128.1.150.105 offset 0.003329 sec
Mar  6 07:15:00 server21 ntpdate[12817]: step time server 128.1.150.105 offset 0.003556 sec
Mar  6 07:30:00 server21 ntpdate[17337]: step time server 128.1.150.105 offset 0.000702 sec
Mar  6 07:45:00 server21 ntpdate[21903]: step time server 128.1.150.105 offset 0.004069 sec
Mar  6 08:00:00 server21 ntpdate[26494]: step time server 128.1.150.105 offset 0.003840 sec
Mar  6 08:15:00 server21 ntpdate[1162]: step time server 128.1.150.105 offset -0.002275 sec
Mar  6 08:26:35 server21 sshd[4710]: SSH: Server;Ltype: Version;Remote: 128.1.150.114-1114;Protocol: 2.0;Client: PuTTY-Release-0.54
Mar  6 08:26:42 server21 sshd[4710]: error: PAM: Authentication failed for tango1 from 128.1.150.114
Mar  6 08:26:45 server21 sshd[4710]: Accepted password for tango1 from 128.1.150.114 port 1114 ssh2
Mar  6 08:27:01 server21 su: + 0 tango1-root

 

2)In mail (outlook) the file seems as :

Mar  6 07:00:00 server21 ntpdate[8270]: step time server 128.1.150.105 offset 0.003329 sec Mar  6 07:15:00 server21 ntpdate[12817]: step time server 128.1.150.105 offset 0.003556 sec Mar  6 07:30:00 server21 ntpdate[17337]: step time server 128.1.150.105 offset 0.000702 sec Mar  6 07:45:00 server21 ntpdate[21903]: step time server 128.1.150.105 offset 0.004069 sec Mar  6 08:00:00 server21 ntpdate[26494]: step time server 128.1.150.105 offset 0.003840 sec Mar  6 08:15:00 server21 ntpdate[1162]: step time server 128.1.150.105 offset -0.002275 sec Mar  6 08:26:35 server21 sshd[4710]: SSH: Server;Ltype: Version;Remote: 128.1.150.114-1114;Protocol: 2.0;Client: PuTTY-Release-0.54 Mar  6 08:26:42 server21 sshd[4710]: error: PAM: Authentication failed for

i tried ux2dos , but still it's same.

 

i also tried the solutin in this thread mentioned by JRF and Laurent , but seems likei am missing something,

http://h30499.www3.hp.com/t5/Languages-and-Scripting/ux2dos-create-a-sign-Z-at-the-end-of-the-text-file/m-p/5259352/highlight/true#M41169

FrogIsDeaf
4 REPLIES 4
Dennis Handly
Acclaimed Contributor
Solution

Re: ux2dos file from unix to dos

>2) In mail (outlook) the file seems as:

 

I think Outlook is combining lines into paragraphs.  I think you need to look for an option that tells it to leave linefeeds alone?

Bill Hassell
Honored Contributor

Re: ux2dos file from unix to dos

You are passing the text the hard way -- and the shell doesn't know that you want to treat the stream of data as text. mailx is much more suitable for scripting:

 

tail -20 /var/adm/syslog/syslog.log | mailx -s "Whatever subject you want" -r rtango@server21.com monitoring@server21.com

 This method eliminates the temp file (which wasn't needed in the original code either) and is much easier to understand.



Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: ux2dos file from unix to dos

>mailx is much more suitable for scripting

 

Yes, using mailx is better than sendmail.

 

>which wasn't needed in the original code either

 

You can't really tell since it was appending to that file.  :-)

Also, I think you have reversed the sendmail -f and -t.  The former takes a from alias parm, the latter says look at the body (and doesn't take a parm).

 

tail -20 /var/adm/syslog/syslog.log >> /tmp/test123.txt
mailx -s "Whatever subject you want" -r monitoring@server21.com rtango@server21.com < /tmp/test123.txt
pranav026
Advisor

Re: ux2dos file from unix to dos

Try Basic text option, with no text formatting allowed. If it helps well and good.