format string output

I need to put the output of the ps -ef command into a string.
echo'n that string must display the output similiar to how we see the output of ps -ef in commandline.

This is the string

message="this is the output of ps command\n\n
`ps -ef`\n\n
Output Complete"

when I echo $message the output should be something like this:

this is the couput of ps command

oracle 23 343 23 .....
oracle 45 453 34
...
...
...

Output Complete

Please let me know

This is not possible. The line breaks and multiple spaces in the "ps" output will be lost.
What do you want to do with $message ? There will no doubt be another way without putting the output from "ps" into an environment variable.

Please also mention what Operating System and version you have and which Shell you are using.

#!/bin/ksh
IFSsav="$IFS"
IFS="XXXXXXXX"
echo "this is the output of ps command\n\n
`ps -ef`\n\n
Output Complete"
IFS="$IFSsav"

Thanks for checking methyl and anurag...anurag ,that is not what I needed

methyl, $message is fed into a monitor tool so that it can display the content of $message . I'm trying this for both hp-ux 11.11 and sun 5.9 OS, shell is ksh.let me know if there is any other way out.

Try this:

message="this is the output of ps command

$(ps -ef)

Output Complete"
echo "$message"
#!/bin/ksh
IFSsav="$IFS"
IFS="XXXXXXXX"
message="this is the output of ps command\n\n
`ps -ef`\n\n
Output Complete"
echo "$message"
IFS="$IFSsav"

Here message variable will have the formated string.
OR the way Scrutinizer suggested.

Thanks. But the output of $message is not the way I wanted.

echo'n that string must display the output similiar to how we see the output of ps -ef in commandline.

the $(ps -ef) when shown in $message does not show the processes line by line, instead they are in one single line all together....

can awk or sed be helpful here in anyway?

The use of proper quoting is essential here. Don't forget to put the double quotes exactly where I put them. I've highlighted them in my previous post.

awk 'BEGIN{print "This is the output of ps command\n"
system("ps -ef")
print "\nOutput Complete\n"}'
message="this is the output of ps command\n\n$(ps -ef)\n\nOutput Complete\n"
printf "$message"

Thanks a lot scrutinizer , it works as I wanted. Thanks everybody for providing your inputs.

this is the output of ps command

     UID     PID    PPID TTY     STIME COMMAND
  Anurag    1856       1 con  00:56:57 /usr/bin/bash
  Anurag   18088    1856 con  01:20:13 /usr/bin/pdksh
  Anurag   13864   18088 con  01:20:13 /usr/bin/ps

Output Complete

This is the output I'm getting.
Make sure you put double quotes around the variable

echo "$message"

Without double qoute, output will be in a single line.