LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-31-2014, 05:25 AM   #1
Saicharan Burle
LQ Newbie
 
Registered: Aug 2014
Posts: 24

Rep: Reputation: Disabled
Shell Script


Hi Team,

I need some help on writing one script for the following requirements:

There are several servers in the server.txt file, In each of the servers, applications have been deployed and installed.

server.txt looks like this:

lxomp95n.qintra.com
lxomavmap578.qintra.com
lxdnp79d.qintra.com
lxdenvmap466.qintra.com
ch3-ctlhcdelxvmpapa03.centurylink.com
lxomvp33v.corp.intranet


Then I ran this for loop from the command prompt
for i in `cat server.txt|grep -v "All"`; do echo $i ;ssh -q $i grep SSLProtocol /opt/apache/qwest/websites/*/conf/ssl.conf;done


when I see output for an apache instance that shows:
SSLProtocol All -SSLv2 -SSLv3

Now i want the condition like for the apps which are not having SSLProtocol and display them as well...
 
Old 12-31-2014, 06:03 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Use exit value of grep command?
 
Old 12-31-2014, 06:21 AM   #3
Saicharan Burle
LQ Newbie
 
Registered: Aug 2014
Posts: 24

Original Poster
Rep: Reputation: Disabled
This is the draft of my script, Let me know if i need to explain any line.... Correct me the right script

#!/bin/bash

cd /u/foss

for i in `cat server.txt|grep -v "All"`;
do
echo $i;
ssh -q $i grep SSLProtocol /opt/apache/qwest/websites/*/conf/ssl.conf;

cd /opt/apache/qwest/websites/

ls > /tmp/poodle.txt

for appname in `awk -F: '{print $1}' /tmp/poodle.txt`
do
echo "Application $((i++)) : $appname"
cd $appname/conf/

if [ `grep SSLProtocol ./ssl.conf` ]
then
echo "$appname: Poodle remidated"; >> /tmp/ssl.txt
else
echo "Need to perform the poodle changes"; >> /tmp/ssl.txt
fi
done
done
 
Old 12-31-2014, 07:39 AM   #4
Saicharan Burle
LQ Newbie
 
Registered: Aug 2014
Posts: 24

Original Poster
Rep: Reputation: Disabled
Hi Team,

Any update?
 
Old 12-31-2014, 09:02 AM   #5
Saicharan Burle
LQ Newbie
 
Registered: Aug 2014
Posts: 24

Original Poster
Rep: Reputation: Disabled
Hi Team,

Can you please suggest me on my script?
 
Old 12-31-2014, 09:37 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Saicharan Burle View Post
Hi Team,
Any update?
...and....
Quote:
Originally Posted by Saicharan Burle
Hi Team,
Can you please suggest me on my script?
Do not bump your own thread..especially not twice in less than two hours. This is a VOLUNTEER forum...we answer when we want to or are able to. Bumping your own thread is fairly rude, and is against the LQ Rules and Question Guidelines (which you should read).

Second, we did suggest you try something on your script...did you do it? unSpawn suggested you use the exit value of the grep command. You posted your script, but don't actually tell us if it's working the way you want to or not, or what the output actually is. We can't guess as to what it is you're seeing.
 
Old 12-31-2014, 10:15 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Saicharan Burle View Post
This is the draft of my script
Thanks for posting but next time please add that to your initial post, OK?

The script could do with some improvements because
- you're changing into a directory and using cat|grep where you could just grep /complete/path/file,
- you're using a "for" loop instead of a "while" loop (http://mywiki.wooledge.org/DontReadLinesWithFor),
- you're not looking ('man find') for configuration files but assuming they're just called "ssl.conf",
- you're not using proper temporary file names ('man mktemp') and I think it would be easier to pull a script in, execute it and have your details on stdout...


More importantly: addressing CVE-2014-3566 only now is criminally negligent behaviour, period. If you want to scan for POODLE then use nmap with the POODLE NSE script. That's more efficient because you avoid reinventing the Wheel.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script for run an shell script on server using ssh bloodstreetboy Linux - Server 5 01-12-2013 03:23 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration