1 Replies - 377 Views - Last Post: 30 September 2013 - 07:22 PM Rate Topic: -----

#1 shaunarman  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 62
  • Joined: 21-January 10

AIX script to only run if AIX is newer then 5.3

Posted 30 September 2013 - 06:00 PM

Hello all, I need a little assistance. I have not done any scripting or programming since I graduated back in 2011 and I am very rusty and need a little help. I need to create a shell script using "ksh", none others will do, that will only run if and only if the AIX version is newer then 5.3. Here is what I have sofar to give you and idea.

My intentions are to run this script recursivly on aprox. 15,000 servers to upgrade the software.
My recursive script:
#!/bin/ksh
#########################################
#       Author: Shaun
#       Contact: myemail@me.com
#       Title: bulkrun.sh
#
#       Description: This script will
#       recursivly run the same script
#       by parsing a server list
#
#       Prereq's: serverlist.txt, and
#       a seperate script that you need
#       to run on multiple servers
##########################################


#Variables
results='run_report.txt' #Results exported to a text file

###########################################################
echo "What is the script you want to run? "
read remotescript

echo "What is your server list? "
read server_file

echo > $results
server_list=`cat $server_file`
for server in $server_list
do
echo >> $results
cat $remotescript | ssh -o BatchMode=yes -o StrictHostKeyChecking=no $server "cat > $remotescript; chmod 755 $remotescript; ./$remotescript; exit" >> $results
echo >> $results



My script that I need a little push with.

#!/bin/ksh


#########################################
#       Author: Shaun
#       Contact: myemail@me.com
#       Title: precheck.sh
#
#       Description: This script will
#       install the software
#
##########################################

# DIs the OS newer then 5.3
if [[ ! = <HELP> ]]; then
    exit
    done
else

# Mount and run software install
/usr/sbin/mount aixdepot\:/depot /depot
cd /depot/director/checkds/
echo "#######################################\n###
hostname >> /install.txt         # enters server hostname as header
./checkds.sh >> /install.txt     #Enters confermation of script being ran
echo "\n\n\n#######################################\n\n\n" >> /install.txt
exit
fi



Any help would be a great help.

Is This A Good Question/Topic? 0
  • +

Replies To: AIX script to only run if AIX is newer then 5.3

#2 Gorian  Icon User is offline

  • ninja DIC
  • member icon

Reputation: 120
  • View blog
  • Posts: 1,681
  • Joined: 28-June 08

Re: AIX script to only run if AIX is newer then 5.3

Posted 30 September 2013 - 07:22 PM

Just an FYI, you CAN install bash on AIX.

To get the os version on AIX, check out the oslevel command, then you can compare the output to see if it's 5.3 or newer or not. Unfortunately, I currently don't have an AIX server to test with, but it should get you started in the right direction. Also, I have a couple scripts (in bash) that i used for pushing to AIX, they may be of use, you are welcome to check them out.
https://github.com/G...tree/master/AIX

Also, check out command substition, that will be useful for getting the output of a command to check it against the expected result:
http://publib.boulde...ll_comm_sub.htm



Also, what I found useful for working with a large number of AIX server, was automating telnet (as AIX 5.3 and 6.1 do not install ssh by default)

I have a tutorial on it here: http://www.dreaminco...doc-and-expect/

This post has been edited by Gorian: 30 September 2013 - 07:51 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1