Mr_G
September 23rd, 2010, 02:38 PM
Hey,
I have a shell script as follows
#!/bin/bash
echo "Enter server number "
read server
echo " Enter path"
read domainpath
if [ "$server" != "" ] && [ "$domainpath" != "" ]
then
case $server in
1) ssh user@server1 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
2) ssh user@server2 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
3) ssh user@server3 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
4) ssh user@server4 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
5) ssh user@server5 "sudo grep $domainpath /usr/local/apache/logs/error_log |less" ;;
*) echo "$server invalid option" ;;
esac
else
echo " Error: Path or Server Number cannot be blank "
exit
fi
The problem is that once the script executes it displays a huge amount of logs even for a particular domain.
Once I kill the script by pressing control c or q putty seems to hang.
Any idea y or How can I improve the script.?
I have a shell script as follows
#!/bin/bash
echo "Enter server number "
read server
echo " Enter path"
read domainpath
if [ "$server" != "" ] && [ "$domainpath" != "" ]
then
case $server in
1) ssh user@server1 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
2) ssh user@server2 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
3) ssh user@server3 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
4) ssh user@server4 "sudo grep $domainpath /usr/local/apache/logs/error_log |less";;
5) ssh user@server5 "sudo grep $domainpath /usr/local/apache/logs/error_log |less" ;;
*) echo "$server invalid option" ;;
esac
else
echo " Error: Path or Server Number cannot be blank "
exit
fi
The problem is that once the script executes it displays a huge amount of logs even for a particular domain.
Once I kill the script by pressing control c or q putty seems to hang.
Any idea y or How can I improve the script.?