Operating System - HP-UX
1748070 Members
5306 Online
108758 Solutions
New Discussion юеВ

Managing variables -very important

 
Marco_ALT
Esteemed Contributor

Managing variables -very important

Hello

I have an operations which give the output in a variable $out

I want to send this output by e-mail, so guys know that the job has been finished.

Simply, i need to write the variable $out to a file, after that i can send it by e-mail.

Can you please help with this?

thanks


13 REPLIES 13

Re: Managing variables -very important

Why do you need to write the value to a file? Am I over-simplifying this?:

echo "Output of operation is <${out}>" | mailx -s "Output of operation" my.email@myaddress.com


Won't that do?

HTH

Duncan


I am an HPE Employee
Accept or Kudo
Marco_ALT
Esteemed Contributor

Re: Managing variables -very important

Hello


can i write this output to a .txt file or .csv file??


thanks

Re: Managing variables -very important

Sure if you want:

echo ${out} > /tmp/myfile.txt

cat /tmp/myfile.txt | mailx -s "Output of operation" my.email@myaddress.com

To a CSV file??? what are you trying to put in comma delimited format??

Maybe you need tyo define your problem statement a bit further

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Laurent Menase
Honored Contributor

Re: Managing variables -very important

do you man as an attachement?

mail myname@myaddr <Subject: fin de job
Content-Type: application/vnd.ms-excel;
name="t1.csv"
Content-Transfer-Encoding: 7bit

$out
.
EOF

Marco_ALT
Esteemed Contributor

Re: Managing variables -very important

Hello

i am trying to write the variable to that file using command

#echo ${out} > /tmp/myfile.txt
but i got this error msg

Result=ChannelExec;returnResult=ChannelExec;returnCode=-1.............................


what is the channedExec error and how i can solve it?

thanks
Hakki Aydin Ucar
Honored Contributor

Re: Managing variables -very important

it seems like a Java application error not HP-UX . Did you use a java code to get this output ?
Dennis Handly
Acclaimed Contributor

Re: Managing variables -very important

>but I got this error msg

Where? On stderr or in tmp/myfile.txt?
Matti_Kurkela
Honored Contributor

Re: Managing variables -very important

If your variable may contain spaces, semi-colons and/or other characters with a special meaning to the shell, put double quotes around it.

echo "${out}" > /tmp/myfile.txt

The semi-colon (;) ends one shell command and begins another. If your variable contains semi-colons and the variable expansion is not quoted, the first semi-colon will terminate the echo command and the rest of the variable content will be interpreted as shell command(s), most likely causing error messages.

MK
MK
Marco_ALT
Esteemed Contributor

Re: Managing variables -very important

i changed it to

echo "${TAP OUT}" > file02.txt;

but still the same error
!!!!
plz advise