Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: rammu_sivraj on June 29, 2006, 06:23:07 AM

Title: Hii. Help me in modifying my script
Post by: rammu_sivraj on June 29, 2006, 06:23:07 AM
# This is my sample script
#!/bin/sh
# script to display file system packages and s/w packages
ech0 -e " system packages " >> /tmp/infoshell.sh
rpm -qa | sort | less >> /tmp/infoshell.sh
echo -e " file system profile " >> /tmp/infoshell.sh
df -a | cut -d" " -f1 >> /tmp/infoshell.sh
cat /tmp/infoshell.sh | more
rm -f /tmp/infoshell.sh

How to make the file infoshell.sh a userfriendly document?? the output of my script is so vague.
help me in viewing the a good o/p.. one should use tab key in scrolling down the o/p page.. plz help
Regards
Rammu
Title: Hii. Help me in modifying my script
Post by: dragoncity99 on July 04, 2006, 06:07:29 AM
# This is my sample script
#!/bin/sh
# script to display file system packages and s/w packages
ech0 -e " system packages " >> /tmp/infoshell.sh
rpm -qa | sort | less >> /tmp/infoshell.sh
echo -e " file system profile " >> /tmp/infoshell.sh
df -a | cut -d" " -f1 >> /tmp/infoshell.sh
cat /tmp/infoshell.sh | more
rm -f /tmp/infoshell.sh

Hi, i think, u'll need to re-organize ur script. It's a bit confusing to read ur script. :p

1. I suggest u do this as a good practice:

Quote

#!/bin/sh
# script to display file system packages and s/w packages

# Step 1 - Write the word " system packages " to file /tmp/infoshell.sh
echo -e " system packages " >> /tmp/infoshell.sh

# Step 2 - Write all the sorted rpm packages to file /tmp/infoshell.sh
rpm -qa | sort | less >> /tmp/infoshell.sh

# Step 3 - Write all th word "file system profile " to file /tmp/infoshell.sh
echo -e " file system profile " >> /tmp/infoshell.sh

# Step 4 - Write the disk usage to file /tmp/infoshell.sh
df -a | cut -d" " -f1 >> /tmp/infoshell.sh

# Step 5 - Read the file /tmp/infoshell.sh and display with "more"
cat /tmp/infoshell.sh | more

# Step 6 - Remove file /tmp/infoshell.sh
rm -f /tmp/infoshell.sh


2. Do not use "less" command in a script to redirect to a file. Omit the "less" command.
Code: [Select]
rpm -qa | sort | [b]less[/b] >> /tmp/infoshell.sh

3. Do not use file with "*.sh" file extension to represent a normal text file. It's a bit misleading.

That's my suggestion.

Cheers,
Dragon