Link to home
Start Free TrialLog in
Avatar of David Aldridge
David AldridgeFlag for United States of America

asked on

Running a command remotely using ksh

I want to loop through all of our Solaris servers using ssh and make sure the patch for shellshock has been applied.  The check for it is this:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

if it prints "vulnerable", you need to have the patch applied.  The problem is that the special characters in that command break when I run through a list of our servers in a for loop trying to ssh to them.  I've tried \ them out, but to no avail.

The loop looks like this:
for i in $serverlist)
do
      ssh $i env x='() { :;}; echo vulnerable' bash -c "echo this is a test" |grep vulnerable
      if [ $? -eq 0 ]
      then
              print $i needs patch
      fi
done



Any help would be appreciated.

David
ASKER CERTIFIED SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Aldridge

ASKER

Thanks! Sorry it took me so long to get back.  I didn't get an email saying an answer had been posted.  Great solution though.