| Janis Papanagnou 2005-10-30, 5:51 pm |
| rouble@gmail.com wrote:
> Hi All,
>
> When I run an external command, I get some formatted output as follows:
>
> sh-3.00# /sbin/apcaccess status
> APC : 001,039,1000
> DATE : Sun Oct 30 15:18:49 EST 2005
> HOSTNAME : example.com
> RELEASE : 3.10.18
> VERSION : 3.10.18 (21 July 2005) debian
> UPSNAME : example-ups1
> CABLE : USB Cable
> MODEL : Back-UPS BR 800
> UPSMODE : Stand Alone
> <SNIP>
>
> I can store this output in a variable as follows:
> sh-3.00# status=`/sbin/apcaccess status`
>
> Now I want to use this output as part of an email body. But when I echo
> it, the output loses its formating:
>
> sh-3.00# echo $status
> APC : 001,039,1000 DATE : Sun Oct 30 15:20:55 EST 2005 HOSTNAME :
> example.com
> RELEASE : 3.10.18 VERSION : 3.10.18 (21 July 2005) debian UPSNAME :
> example-ups1 CABLE : USB Cable MODEL : Back-UPS BR 800 UPSMODE :
> Stand Alone
> STARTTIME: Sat Oct 29 22:11:13 EDT 2005 STATUS : ONLINE LINEV : 000.0
> Volts
>
> Any clues as to how I can keep the formatting ? I tried 'echo -e' to no
> avail.
Try this...
IFS=
status=`...`
echo $status
Janis
|