5 Replies Latest reply on Mar 31, 2013 9:02 PM by Bill Robinson

    Need some help with shell scripting

    Charles Berman

      Hello,

             I have a situation where I have been thrown into creating a shell script for BL with no knowledge of the tool.

       

                I need to run a script from a windows based BL server to dozens of AIX servers. The Unix protion of the shell script is done and creates a one line csv file.

       

                I don't know how to push or pull the file back to the windows server and then have each entry from each server create one file.

       

                I also don't know what would need to be placed at the top of the file if any thing.

       

                Should I push my Ksh script to the server and run it or should it be incorprated into the nsh script?

       

                Any and all help is appricated.

       

       

      Thank you,

       

       

      Charlie

        • 1. Re: Need some help with shell scripting
          Bill Robinson

          what do you need to do w/ the csv after you get it back on the windows box?

           

          can you paste the shell script you are trying to run ?

          • 2. Re: Need some help with shell scripting
            Siddu angadi

            Hi Charles,

             

            use the BLPackage or NSHScript type 3 to trigger your shell commands to generate CSV file on target AIX box.

            Look at the 'cp' in the NSHScripting.

             

            As example:

             

            TargetServer="hostname of your windows box"

            SourceServer=$1    ##-- basically NSHscript parameter -- TARGET.NAME property

             

            cp -f //${SourceServer}/tmp/test.csv //${SourceServer}/c/temp

             

             

            Thank

            Siddu

            • 3. Re: Need some help with shell scripting
              Bill Robinson

              if he needs to pull the csv back to the appserver, using a blpackage is out, so is a type 3 nsh script.

               

              depending on what his script does, it may be possible to convert it right to nsh and run a few commands via nexec. 

              • 4. Re: Need some help with shell scripting
                Charles Berman

                This is the entire script that as it would need to be run on the AIX server.

                 

                It will produce a single line file that has ',' in it. But each file one each server would needed to be concatinated at the host server where a master file would be created.

                 

                 

                 

                lslpp -L gpfs.base

                X=`echo $?`

                if [ $X = 0 ]; then

                echo "$(uname -n)," $( lslpp -L gpfs.base|sed -n '3p'|awk '{print $1, $2}')> /tmp/gpfs.txt

                else

                echo "$(uname -n), File set not installed" > /tmp/gpfs.txt

                fi

                • 5. Re: Need some help with shell scripting
                  Bill Robinson

                  so you could do this as a type 1 or type 2.  if you need to combine the results in to a single file, you can either do a type 1 to get the results, and a type 2 to combine them, or just a type 2.  the type 2 will need to loop through all the targets where as the type 1 would not...

                   

                  anyway - as a type 2 you could do like:

                   

                   

                  for server in $@

                  do

                  nexec -i -l ${server} sh -c "lslpp -L gpfs.base"

                  X=$?

                  if [[ $X = 0 ]]

                  then

                  echo "${server},$(nexec -i -l ${server} sh -c "lslpp -L gpfs.base|sed -n '3p'|awk '{print $1, $2}')" >> //SOMESERVER/tmp/gpfs.txt

                  else

                  echo "${server}, File set not installed" >> //SOMESERVER/tmp/gpfs.txt

                  fi

                  done