df script output issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting df script output issue
# 1  
Old 07-07-2012
Question df script output issue

hi all,i m using this script for disk space :



Code:
####################################
#!/bin/ksh
#
HOSTS='/usr/bin/cat /host_list'
DATE=$(date)
DISK=$(df -gt)
afile=/tmp/diskspace.log
>$afile
#
   for i in $HOSTS
 
do 
 
    echo ip: $i passed
    echo ip: $i passed >>$afile
    echo date: $DATE checked >>$afile
    echo disk space: $DISK checked
    echo disk space: $DISK checked >>$afile
    cat /tmp/1 >>$afile
 
done
 
#######################################

the output i m getting is :

Code:
filesystem GB blocks Free used Free %used Mounted on /dev/hd4 4.00 1.62 2.38 57% /usr......................

I want this to be like this:

Code:
Filesystem     GB blocks     Used     Free      %used    Mounted on
/dev/hd4         4.00            1.62      2.38        57%          /usr

Please give some suggestions!!!!!!!!!!!!!!
I m using AIX

Thanks

Last edited by methyl; 07-07-2012 at 06:57 PM.. Reason: plase use code tags
# 2  
Old 07-07-2012
Please use code tags for your code. Try this:
Code:
#!/bin/ksh
#
HOSTS='/usr/bin/cat /host_list'
DATE=$(date)
DISK=$(df -gt)
afile=/tmp/diskspace.log
>$afile
#
for i in $HOSTS

do 

echo ip: $i passed
echo ip: $i passed >>$afile
echo date: $DATE checked >>$afile
echo disk space: "$DISK" checked
echo disk space: "$DISK" checked >>$afile
cat /tmp/1 >>$afile

done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

2. HP-UX

[Solved] HTML Email output issue

Hi All, I am facing issue while trying to send an HTML email using my HP-UX server. I am trying to send some color codes to be drawn in the output, but in the output the correct color is not appearing. It is appearing some shades of green all the time. I referred to w3 website for the color... (5 Replies)
Discussion started by: chpsam
5 Replies

3. Shell Programming and Scripting

Issue with output redirection

Hi, I am using AIX server. I have a korn shell script where in I am redirecting a line to a file in a while loop: while read line do outputline=$line; echo $outputline >> "./temp/exec_list_"$ETL_JOB_RUN"_temp" done < ./temp/exec_list_$ETL_JOB_RUN Sometimes, when the CPU... (2 Replies)
Discussion started by: pmonika
2 Replies

4. Shell Programming and Scripting

While loop wired output issue

Hi, Wired output I am getting. Pls let me know what mistake i did on below loop script paste profile.txt names.txt | while read i j do echo >> profiles.ini echo Name=$j >> profiles.ini echo IsRelative=1 >> profiles.ini echo Path=Profiles/$j >> profiles.ini done ... (3 Replies)
Discussion started by: ranjancom2000
3 Replies

5. Shell Programming and Scripting

Format output issue

Dear Friends, Need your help. $cat input.txt TITLE Date:01-01-2011 Day: Friday Details Particulares Qty $ $ $ $ $ $more test.sh cat input.txt | while read line do echo "${line}" done $ $ (5 Replies)
Discussion started by: anushree.a
5 Replies

6. Shell Programming and Scripting

Issue with redirecting output from crontab

Hello All, I've scheduled one simple command to be run from crontab, but the command is failing to append the output to a file. Any issue in my syntax ? This rah cmd is working fine from command center. 19 09 * * * rah "df -m" | awk '{if (NF > 1) if ($5 ~ /NODE/) {print $0;}}' >> db.out 2>&1... (1 Reply)
Discussion started by: NARESH1302
1 Replies

7. Infrastructure Monitoring

Nagios script output issue

Hi Folks, Nagios is acting a little weird for me, I have this external script which I hooked into Nagios, it merely does a curl/wget on a URL and returns the status based on string in the content/output. Initially for 2-3 hrs the script returns the right status and Nagios reports correctly i.e.... (4 Replies)
Discussion started by: jacki
4 Replies

8. Solaris

Duplex Script - output format issue.

Hi Gurus, I had downloaded the below script from the net and used it to get the Link and duplex settings in my Sun servers. In all except one(Sol-5.10 on X86) i am getting output format like below: root: /var/ADMIN/bin/speed_duplex.sh Interface Speed Duplex --------- ... (2 Replies)
Discussion started by: Hari_Ganesh
2 Replies

9. UNIX for Dummies Questions & Answers

Issue with crontab output

Hi , I have this crontab job which is not able to write a db2 command output to a file . The output file comes out to be of file zero and it sends me wrong alerts . cat indoubt_transaction.shl #!/bin/ksh... (1 Reply)
Discussion started by: capri_drm
1 Replies

10. Shell Programming and Scripting

issue with the query output in unix

I am running a query with contains blank spaces in between in the output. But when I open and read the file in UNIX i am not able to cursor the balnk spaces instead it is moving like tabs. Please help suppose my query - Select ' '||text from tab1; the cursor should move to 1st and... (1 Reply)
Discussion started by: sbmk_design
1 Replies
Login or Register to Ask a Question